Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

array_key_exists but with an object as the key

Tags:

php

What's the best way to check if an object exists as the key of an array?

// key: $obj, array: $array
array_key_exists($obj, $array);

Results in a PHP Warning: "1st param should be string or integer".

like image 491
cid Avatar asked Dec 21 '25 19:12

cid


1 Answers

I'm pretty sure you're wanting property_exists()

edit: at time of answer, the title was "array_key_exists but with objects"

like image 197
Brad Kent Avatar answered Dec 24 '25 08:12

Brad Kent