3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $test = 'sd'; private $test2 = [ 'test' => true, 'foo' => ['test'=>'asdasdads' ] ]; } function dismount($object) { $reflectionClass = new ReflectionClass(get_class($object)); $array = array(); foreach ($reflectionClass->getProperties() as $property) { $property->setAccessible(true); $array[$property->getName()] = $property->getValue($object); $property->setAccessible(false); } return $array; } $foo = new Foo; print_r( dismount($foo));

preferences:
57 ms | 402 KiB | 5 Q