sandy1028 Posted November 9, 2010 Share Posted November 9, 2010 $LinksText = array(); for ($i=0; ($i < $cnt && $i < $total); $i++ ) { $Text = explode ('#', $Links[$i]); $LinksText[]=$Text[1]; } $count = count($LinksText); print_r(LinksText); print count($LinksText); if($count > 0){ echo "I am not zero" } else { echo "I am zero" } output: Array ( [0] => [1] => ) 2 Please tell me why the array count is 2. Quote Link to comment Share on other sites More sharing options...
anups Posted November 9, 2010 Share Posted November 9, 2010 count will give you number of elements in array. in other words it will give you the number of array keys. it doesn't depend upon the value of key. for e.g. $arr = array(); $arr[0] = array(1,2,3,4,5,6); $arr[1] = array(11,22,33,44,55,66); $arr[2] = ''; in this case count ($arr) will give you 3. Quote Link to comment Share on other sites More sharing options...
sandy1028 Posted November 9, 2010 Author Share Posted November 9, 2010 Thanks. How can I print based on count now. If all the values are empty, then I have print "I am in zero loop" else "I am not in zero lop" Quote Link to comment 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.