Source Code:
(back to article)
<?php $data = array( array("name" => "John", "age" => 25), array("name" => "Jane", "age" => 30), array("name" => "Jim", "age" => 35) ); $people = array_reduce($data, function($carry, $item) { $carry[$item["name"]] = $item["age"]; return $carry; }, array()); print_r($people); ?>
Result:
Report an issue