- var_dump: documentation ( source)
- array_column: documentation ( source)
<?php
class aa implements ArrayAccess
{
protected $_data = array();
public function offsetGet($key)
{
return $this->_data[$key];
}
public function offsetSet($key, $value)
{
$this->_data[$key] = $value;
}
public function offsetExists($key)
{
return isset($this->_data[$key]);
}
public function offsetUnset($key)
{
unset($this->_data[$key]);
}
}
$a = new aa;
$a['name'] = 'Dżozef';
$a['id'] = 5;
$b = array();
$b[0] = $a;
$b[1] = array(
'name' => 'Kinszasa',
'id' => 17,
);
var_dump(array_column($b, null, 'id'));