- array_column: documentation ( source)
- print_r: documentation ( source)
<?php
class Foo
{
private $name;
private $value;
public function __construct($name, $value)
{
$this->name = $name;
$this->value = $value;
}
public function __get($prop)
{
return $this->$prop;
}
public function __isset($prop)
{
return isset($this->$prop);
}
}
$ar = [
new Foo('foo', 'a'),
new Foo('bar', 'b'),
new Foo('baz', 'c')
];
print_r(array_column($ar, 'value', 'name'));