3v4l.org

run code in 300+ PHP versions simultaneously
<?php $object = new stdClass(); $object->id = 12; $object->datetime = new \DateTime(); $object->foo = 'foo'; $object->bar = 'foo'; $object->a = 'foo'; $object->b = 'foo'; $object->c = 'foo'; $object->d = 'foo'; $object->e = 'foo'; /* @var callable $toArray */ $toArray = null; $toArray = function ($object) use (&$toArray) { $array = []; foreach ($object as $key => $attribute) { if ($attribute instanceof \DateTime) { $array[$key] = $attribute->format('c'); } elseif (is_object($attribute) || is_array($attribute)) { $array[$key] = $toArray($attribute); } else { $array[$key] = $attribute; } } return $array; }; for ($i = 0; $i < 1000; $i++) { $toArray($object); } var_dump($toArray($object));
Output for git.master, git.master_jit, rfc.property-hooks
array(9) { ["id"]=> int(12) ["datetime"]=> string(25) "2015-05-06T10:14:01+02:00" ["foo"]=> string(3) "foo" ["bar"]=> string(3) "foo" ["a"]=> string(3) "foo" ["b"]=> string(3) "foo" ["c"]=> string(3) "foo" ["d"]=> string(3) "foo" ["e"]=> string(3) "foo" }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
55.71 ms | 401 KiB | 8 Q