This time I am going to correct myself in indeting. Thanks CTphpnwb to note me that again.this time I take this is serious.
18 Replies - 961 Views - Last Post: 10 July 2012 - 04:15 AM
#16
Re: implementing count method in php
Posted 09 July 2012 - 07:13 AM
actually this is not the firstime I was redirect to this external link.
This time I am going to correct myself in indeting. Thanks CTphpnwb to note me that again.this time I take this is serious.
This time I am going to correct myself in indeting. Thanks CTphpnwb to note me that again.this time I take this is serious.
#17
Re: implementing count method in php
Posted 09 July 2012 - 11:57 AM
It should also be noted that your function will not return the proper count if there are gaps in the indexes:
This:
Will incorrectly return a value of 2.
This:
<?php
//function to count number of elemenst in a array
function mee($arr){
$i=0;
while(isset($arr[$i])){
$i++;
}
return $i;
}
$test = array();
$test[0] = "This";
$test[1] = "is";
$test[4] = "a";
$test[5] = "test";
echo mee($test);
?>
Will incorrectly return a value of 2.
#18
Re: implementing count method in php
Posted 09 July 2012 - 04:07 PM
#19
Re: implementing count method in php
Posted 10 July 2012 - 04:15 AM
Haha so you did, I somehow missed that
|
|

New Topic/Question
Reply




MultiQuote





|