Return to Snippet

Revision: 58425
at July 13, 2012 23:54 by MonsterDev


Initial Code
public static function recursive_array_key_search($needle, $key, $haystack)
	{
		$recursive_array_key_search = false;

		if (in_array($needle, $haystack)) {
			$recursive_array_key_search = true;
		} else  {
			foreach( $haystack as $key1 => $val ) {
				if(is_array($val)) {
					if(self::recursive_array_key_search($needle, $key, $val)) {
						$recursive_array_key_search = true;
						break;
					}
				}
			}
		}
		return $recursive_array_key_search;
	}

Initial URL

                                

Initial Description
Search recursively some value in array with the key name

Initial Title
Recursive Array Key Search

Initial Tags
search, array

Initial Language
PHP