Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. function freqCount($arr, $el, $level = 0, &$return = []) {
  2. if (!isset($return[$level])) {
  3. $return[$level] = [$level, 0];
  4. }
  5.  
  6. foreach ($arr as $value) {
  7. if (is_array($value)) {
  8. freqCount($value, $el, $level+1, $return);
  9. } else {
  10. if ($value == $el) {
  11. $return[$level][1]++;
  12. }
  13. }
  14. }
  15.  
  16. return $return;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement