php - in_array - 'in_object' equivalent? -


is there such function in_array, can used on objects?

nope, can cast object array , pass in_array().

$obj = new stdclass; $obj->one = 1; var_dump(in_array(1, (array) $obj)); // bool(true) 

that violates kinds of oop principles though. see comment on question , aron's answer.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -