3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Test { public $a = 'a'; protected $b = 'b'; private $c = 'c'; } function objectToArray ($object) { $array = (array) $object; return array_combine( array_map( function($k) { return str_replace("\0", "", $k); }, array_keys($array) ), array_values($array) ); } $array = objectToArray( new \Test()); var_export((array) new \Test());
Output for 7.1.17
array ( 'a' => 'a', '' . "\0" . '*' . "\0" . 'b' => 'b', '' . "\0" . 'Test' . "\0" . 'c' => 'c', )