- var_dump: documentation ( source)
<?php
class ArrayHash extends \stdClass
{
public static function from(array $arr)
{
$obj = new static;
foreach ($arr as $key => $value) {
$obj->$key = $value;
}
return $obj;
}
}
$one = array('abcdef' => 'xxx', '102787' => 'yyy');
$two = (array) ArrayHash::from($one);
echo "# One\n";
var_dump($one);
var_dump(isset($one['abcdef']));
var_dump(array_key_exists('abcdef', $one));
var_dump(isset($one[102787]));
var_dump(array_key_exists(102787, $one));
var_dump(isset($one['102787']));
var_dump(array_key_exists('102787', $one));
echo "\n\n";
echo "# Two\n";
var_dump($two);
var_dump(isset($two['abcdef']));
var_dump(array_key_exists('abcdef', $two));
var_dump(isset($two[102787]));
var_dump(array_key_exists(102787, $two));
var_dump(isset($two['102787']));
var_dump(array_key_exists('102787', $two));
echo "\n\n";