Possible duplicate:
check if the array has one or more empty values
What is the best / easiest way to check if an array has any values? I myself installed the keys, no matter what, I can not go on the keys. My code will show what I'm doing and want to do:
$array = array( "Birthday" => $row3['birthday'], "Sex" => $row3['sex'], "Lives In" => $row3['livesIn'] ); if(empty($array)) { foreach($array as $key => $value) { if($value) { echo "<tr><td>".$key."</td><td>".$value."</td></tr>"; } } } else { echo "This user has not provided any information yet"; }
So, for example, if $row3['birthday'] , $row3['sex'] , $row3['livesIn'] all empty, then it should make the first if statement false and go to the else statement.
source share