sungpeng Posted May 11, 2009 Share Posted May 11, 2009 while($index<=1000) { $arr =$_SESSION['hello'][$index]; echo count($arr); } Check I need a function that will count the number of $arr that is not empty. If got 10 $arr that is not empty or = zero, display 10. The above code display 00000000100000010000. This is not I need. Quote Link to comment https://forums.phpfreaks.com/topic/157661-solved-count-the-number-of-variable-that-is-not-empty/ Share on other sites More sharing options...
Ken2k7 Posted May 11, 2009 Share Posted May 11, 2009 $count = 0; while ($index <= 1000) { if (empty($_SESSION['hello'][$index])) $count++; $index++; } echo $count; Quote Link to comment https://forums.phpfreaks.com/topic/157661-solved-count-the-number-of-variable-that-is-not-empty/#findComment-831373 Share on other sites More sharing options...
sungpeng Posted May 11, 2009 Author Share Posted May 11, 2009 Ok Thank Quote Link to comment https://forums.phpfreaks.com/topic/157661-solved-count-the-number-of-variable-that-is-not-empty/#findComment-831377 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.