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

H

How Can We Help?

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

About the author

Ian Carnaghan

I am a software developer and online educator who likes to keep up with all the latest in technology. I also manage cloud infrastructure, continuous monitoring, DevOps processes, security, and continuous integration and deployment.

About Author

Ian Carnaghan

I am a software developer and online educator who likes to keep up with all the latest in technology. I also manage cloud infrastructure, continuous monitoring, DevOps processes, security, and continuous integration and deployment.

Follow Me