note 102449 added to function.in-array
| From: | JorisMeijer at osu1 dot php dot net | Date: | Tue, 15 Feb 2011 13:31:28 +0000 |
| Subject: | note 102449 added to function.in-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-177005@lists.php.net to get a copy of this message | ||
A good option if your array contains objects and you wish to recursively search it (eg. with
in_arrayr), is to use json_encode and json_decode first:
<?php
$array = json_decode(json_encode($array_with_objects), true);
?>
In my opinion this is more elegant than a recursive in_array function which converts the objects
into arrays while searching for a key and/or value.
----
Server IP: 83.137.20.135
Probable Submitter: 82.92.209.94
----
Manual Page -- http://www.php.net/manual/en/function.in-array.php
Edit -- https://master.php.net/note/edit/102449
Del: integrated -- https://master.php.net/note/delete/102449/integrated
Del: useless -- https://master.php.net/note/delete/102449/useless
Del: bad code -- https://master.php.net/note/delete/102449/bad+code
Del: spam -- https://master.php.net/note/delete/102449/spam
Del: non-english -- https://master.php.net/note/delete/102449/non-english
Del: in docs -- https://master.php.net/note/delete/102449/in+docs
Del: other reasons-- https://master.php.net/note/delete/102449
Reject -- https://master.php.net/note/reject/102449
Search -- https://master.php.net/manage/user-notes.php