Advertisement
voodooKobra

Recursive Key Exists

Apr 6th, 2015
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.38 KB | None | 0 0
  1. <?php
  2. function recursiveKeyExists($search = '', array $array = array())
  3. {
  4.     foreach ($array as $key => $value) {
  5.         if (is_array($value)) {
  6.             $found = recursiveKeyExists($search, $value);
  7.             if ($found) {
  8.                 return true;
  9.             }
  10.         }
  11.         if ($key === $search) {
  12.             return true;
  13.         }
  14.     }
  15.     return false;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement