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

10 sec read

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

Last Updated On March 22, 2018

Leave a Reply

avatar
  Subscribe  
Notify of