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

jQuery clickable div with working mailto link inside -

WPF: binding viewmodel property of type DateTime to Calendar inside ItemsControl -

java - Getting corefrences with Standard corenlp package -