bluwe Posted February 11, 2007 Share Posted February 11, 2007 I want to check if all the values in an array are empty and if this is true echo a message or something. However, I don't want to echo anything if just one value in the array is not empty...I hope I have explain this ok! Can anyone help with this? Thanks! Link to comment https://forums.phpfreaks.com/topic/37966-checking-all-values-in-an-array/ Share on other sites More sharing options...
JasonLewis Posted February 11, 2007 Share Posted February 11, 2007 ummm, there may be a quicker way. but here is one way: $array = array("Key" => '', "Key2" => '', "Key3" => ''); $blanks = true; foreach($array as $key => $val){ if($val != ""){ $blanks = false; break; } } if($blanks){ echo "All array values are empty!"; } enjoy. Link to comment https://forums.phpfreaks.com/topic/37966-checking-all-values-in-an-array/#findComment-181718 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.