I've already trying array_key_exists(), but when it should return the expected result, lumen display error message that I need to use another php function instead of array_key_exists() like isset() or property_exists() as mentioned in this question title.
$jsonData = "mydata.json";
$content = file_get_contents($jsonData);
$unsortedData = json_decode($content, true);
//convert array to object
$object = (object) $unsortedData;
$key = $request->input('key');
$keyData = "false";
if(array_key_exists($key, $object))
{
$keyData = "true";
}
// usort($unsortedData, function($a, $b){
// return $a['no'] > $b['no'];
// });
return $keyData;
// var_dump($unsortedData);
Which one should be used and how to use it?
array_key_exists()used to work with objects but that behavior was deprecated in PHP 7.4.0 and removed in PHP 8 :So, you can change your code to :