3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = array('1' => 'One',); $a['2'] = 'Two'; $o = (object)$a; $o->{3} = 'Three'; $o->{'4'} = 'Four'; foreach( $o as $k => $v ){ var_dump( $k ); } echo "\n"; var_dump( $o ); echo "\n\n"; $a = (array)$o; foreach( $a as $k => $v ){ var_dump( $k ); } echo "\n"; var_dump( $a ); echo "\n\n"; $a = (array)json_decode(json_encode($a)); foreach( $a as $k => $v ){ var_dump( $k ); } echo "\n"; var_dump( $a );
Output for git.master, git.master_jit, rfc.property-hooks
string(1) "1" string(1) "2" string(1) "3" string(1) "4" object(stdClass)#1 (4) { ["1"]=> string(3) "One" ["2"]=> string(3) "Two" ["3"]=> string(5) "Three" ["4"]=> string(4) "Four" } int(1) int(2) int(3) int(4) array(4) { [1]=> string(3) "One" [2]=> string(3) "Two" [3]=> string(5) "Three" [4]=> string(4) "Four" } int(1) int(2) int(3) int(4) array(4) { [1]=> string(3) "One" [2]=> string(3) "Two" [3]=> string(5) "Three" [4]=> string(4) "Four" }

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:
67.69 ms | 402 KiB | 8 Q