Searching an object for a value (like in_array) - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Searching an object for a value (like in_array) (/showthread.php?tid=16834) |
Searching an object for a value (like in_array) - El Forum - 03-17-2009 [eluser]tdktank59[/eluser] Is there a way to do this with objects. Im not sure thus why im asking. Otherwise ill try/use in_array and hope it works lol Searching an object for a value (like in_array) - El Forum - 03-17-2009 [eluser]bretticus[/eluser] You can use the PHP5 functions get_class_vars() and get_class_methods() to make associative arrays to search in or even use method_exists() or property_exists() to search for them directly. Searching an object for a value (like in_array) - El Forum - 03-17-2009 [eluser]tdktank59[/eluser] thanks ill give that a try Searching an object for a value (like in_array) - El Forum - 03-17-2009 [eluser]tdktank59[/eluser] Allright new question! So ive got an object/array called $this->user_permissions Heres what it contains Quote:stdClass Object I need to search this for $class->$method (both are defined. where its Type => Class => Method in the array structure above I guess I can go through it but im trying to find a more efficient way to check if I have access |