- array_column: documentation ( source)
- print_r: documentation ( source)
<?php
class Foo
{
public $id;
public function __construct(){
static $counter = 0;
$this->id = $counter;
++$counter;
}
}
$collection = [new Foo(), new Foo(), new Foo(), new Foo()];
print_r(array_column($collection, 'id'));