On 8/17/05, Ing. Josué Aranda <josuearanda@xxxxxxxxx> wrote: > OK this the little function i made to solve this.. > > function countNested($array){ > foreach($array as $value){ > if(is_array($value)) > $total=$this->countNested($value)+$total; > }else{ > $total=$total+1; > } > } > return $total; > } Looks OK-ish - there's a missing '{' on the third line but apart from that it should work fine as a class method. > any optimizations are welcome.... You can simplify the if-block as below, which might save you as much as a microsecond or two :-) function countNested($array){ $total = 0; foreach ($array as $value) { $total += is_array($value) ? $this->countNested($value) : 1; } return $total; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php