I have an array data like this
$array = Array (
[abc] => Array ( )
[def] => Array ( )
[hij] => Array ( )
[media] => Array (
[video_info] => Array ( )
[video_variants] => Array ( )
[1] => Array ( )
[2] => Array ( )
)
)
My code looks something like this
foreach($response->extended_entities->media as $media)
{
stuffs
foreach ($media->video_info->variants as $video)
{
stuffs
}
}
I want to check whether the "video_info Key is available in the array or not
I have tried this function but it doesn't work
function multi_array_key_exists($key, $array) {
if (array_key_exists($key, $array))
return true;
else {
foreach ($array as $nested) {
foreach ($nested->media as $multinest) {
if (is_array($multinest) && multi_array_key_exists($key, $multinest))
return true;
}
}
}
return false;
}
if (multi_array_key_exists('video_info',$response) === false)
{
return "failed";
}
Please help me
Original array - https://pastebin.com/2Qy5cADF