How to check if an array contains a empty element or value

No Comments

Use the following code example

$array = array('a','b',''); //The array to check for empty values
echo (in_array('  ', $array)) ? 'Empty values exists' :'No empty values'; ?> //Checking if empty values exist in the array

NOTE:

in_array = searches a array for a specific value

Image Credits: Photo by Isis França on Unsplash.

Last Updated On March 22, 2018

Related Articles

No results found

Leave a Reply

avatar
  Subscribe  
Notify of
Menu
Copy link