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