Voting

: eight minus one?
(Example: nine)

The Note You're Voting On

kon
12 years ago
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
)
);
?>

<< Back to user notes page

To Top