I wonder if there is a way to break the rest of walking through an array when you found your desired result:
array_walk($arr, function($value, $key)
{
if($value == "test")
{
global $id;
$id = $key;
break; // I know that break doesn't work! that's just for example.
}
});
The above example shows what I mean by jumping out from array_walk