note 110757 added to function.array-reduce
| From: | kon | Date: | Mon, 03 Dec 2012 13:12:56 +0000 |
| Subject: | note 110757 added to function.array-reduce | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-192258@lists.php.net to get a copy of this message | ||
Walking down related object's properties using array_reduce:
<?php
$a=new stdClass;
$a->b=new stdClass;
$a->b->c="Hello World!\n";
$reductionPath=array("b","c");
print_r(
array_reduce(
$reductionPath,
function($result, $item){
return $result->$item;
},
$a
)
);
?>
----
Server IP: 62.2.182.223
Probable Submitter: 77.58.126.49
----
Manual Page -- http://www.php.net/manual/en/function.array-reduce.php
Edit -- https://master.php.net/note/edit/110757
Del: integrated -- https://master.php.net/note/delete/110757/integrated
Del: useless -- https://master.php.net/note/delete/110757/useless
Del: bad code -- https://master.php.net/note/delete/110757/bad+code
Del: spam -- https://master.php.net/note/delete/110757/spam
Del: non-english -- https://master.php.net/note/delete/110757/non-english
Del: in docs -- https://master.php.net/note/delete/110757/in+docs
Del: other reasons-- https://master.php.net/note/delete/110757
Reject -- https://master.php.net/note/reject/110757
Search -- https://master.php.net/manage/user-notes.php