HTML
<br> //Example array search depth<br> $src_array = array(<br> 'test' => '123',<br> array(<br> 'has' => 'OK',<br> 'find'=> true,<br> array(<br> 'depth' => 'soso',<br> array(<br> '123' => 'wangbin',<br> 'wangbin' => 'wangbin456',<br> array(<br> 'wangbin' => 'wangbin123',<br> ), <p> ),<br> ),<br> ),<br> );<br> </p>
php
function find_array_key($find, $src_array)
{
If (is_array($src_array))
{
$src = '';
If (isset($src_array[$find]))
{
$src .= $src_array[$find];
#Can be improved to delete the found value in search
return $src;
}else
{
foreach ($src_array as $key => $value)
{
If (IS_ARAY ($ Value)) #determine whether an array is an array.
{
return find_array_key($find, $value);
}
}
return false;
}
}else{
return false;
}
}
'test' => '123',
array(
'has' => 'OK',
'find'=> true,
array(
'depth' => 'soso',
array(
'123' => 'wangbin',
'wangbin' => 'wangbin456',
array(
'wangbin' => 'wangbin123',
),
),
),
);
if($username){
echo find_array_key($username, $src_array);
}else{
echo 'Find failed';
}
?>