Source Code:
(back to article)
<?php $objects = [(object) ['id' => 1, 'name' => 'Alice'], (object) ['id' => 2, 'name' => 'Bob'], (object) ['id' => 3, 'name' => 'Charlie']]; $names = array_map(function ($object) { return get_object_vars($object)['name']; }, $objects); print_r($names); // $names is now ['Alice', 'Bob', 'Charlie']
Result:
Report an issue