- print_r: documentation ( source)
<?php
class ArrayClass implements ArrayAccess {
private $container = [];
public function __construct(array $array) {
$this->container = $array;
}
public function offsetSet($offset, $value) {
if (is_null($offset)) {
$this->container[] = $value;
} else {
$this->container[$offset] = $value;
}
}
public function offsetExists($offset) {
return isset($this->container[$offset]);
}
public function offsetUnset($offset) {
unset($this->container[$offset]);
}
public function offsetGet($offset) {
return $this->offsetExists($offset) ? $this->container[$offset] : false;
}
}
$_POST['aa'] = "dd";
$_POST['bb'] = "xd";
$post = new ArrayClass($_POST);
print_r(
[
$post['aa'],
$post['bb'],
$post['cc'],
$post
]
);