'How to check whether the key is present inside the array of stdclass objects in php?

i have two arrays one is the type of stdclass object and another one is normal array like this

$array1 = ['name'=>'laravel','duration'=>'40']; // noraml-array
//array2 is a stdobject array
$array2 = [
  0 => {#3954
    +"name": "php"
    +"duration": "30"
  }
  1 => {#3900
    +"author": "apiato"
    +"duration": "15"
  }
]

i am writing one function in a generic way inside that i want to add one check weather name key exists or not for that i am using array_key_exists function it works fine for normal array,but it's not working for $array2 ,can you please help me how to differentiate both arrays or how to check with array_key_exists() only...?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source