[Solved] How can I count the keys inside a for each loop?
[ad_1] function findKey($array, $keySearch) { global $count; foreach ($array as $key => $item) { if (stripos($key, $keySearch) !== false){ $count++; echo “<li>”.$key.”</li>”; } if (is_array($item)){ findKey($item, $keySearch); } } } $count = 0; findKey($array, $keySearch); echo “Total number of keys: “.$count; 7 [ad_2] solved How can I count the keys inside a for each loop?