- print_r: documentation ( source)
<?php
class MyThing implements \ArrayAccess {
protected $storage = [];
public function __construct($values = array()) {
foreach ($values as $name => $value) {
$this->offsetSet($name, $value);
}
}
public function offsetGet($name) {
if (isset($this->storage[$name])) {
return $this->storage[$name];
}
}
public function offsetSet($name, $value) {
$this->storage[$name] = $value;
}
public function offsetUnset($name) {
unset($this->storage[$name]);
}
public function offsetExists($name) {
return isset($this->storage[$name]);
}
}
function printArray(array $a) {
print_r($a);
}
$thing = new MyThing(['foo' => 'bar']);
printArray($thing);