+ 2

How can i create function with php that counts array length using foreach loop?

<?php function count_arr($array, limit) $count = 0; foreach ($array as $id => $_array){ $count += count_recursive ($_array, $limit - 1) }else { $count +=1; } } return $count; } ?>

13th Jun 2017, 6:56 AM
shubham borghare
shubham borghare - avatar
1 Resposta
+ 1
easier to use the built-in function in php sizeof() or count()
14th Jun 2017, 1:05 AM
Kevin Gilkey-Graham
Kevin Gilkey-Graham - avatar