3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $a = json_decode('{"3":{"friend":45,"all":100},"2":{"friend":30,"all":50},"1":{"friend":25,"all":25}}'); $b = (array) $a; $n = '3'; var_dump($b); var_dump($b["3"]);

Shows result from various feature-branches currently under review from the php developers. Contact me to have additional branches featured.

Output for Typed properties v2
array(3) { [3]=> object(stdClass)#1 (2) { ["friend"]=> int(45) ["all"]=> int(100) } [2]=> object(stdClass)#3 (2) { ["friend"]=> int(30) ["all"]=> int(50) } [1]=> object(stdClass)#4 (2) { ["friend"]=> int(25) ["all"]=> int(25) } } object(stdClass)#1 (2) { ["friend"]=> int(45) ["all"]=> int(100) }
Output for Arrow functions
array(3) { [3]=> object(stdClass)#1 (2) { ["friend"]=> int(45) ["all"]=> int(100) } [2]=> object(stdClass)#3 (2) { ["friend"]=> int(30) ["all"]=> int(50) } [1]=> object(stdClass)#4 (2) { ["friend"]=> int(25) ["all"]=> int(25) } } object(stdClass)#1 (2) { ["friend"]=> int(45) ["all"]=> int(100) }
Output for Object typehint
array(3) { ["3"]=> object(stdClass)#1 (2) { ["friend"]=> int(45) ["all"]=> int(100) } ["2"]=> object(stdClass)#3 (2) { ["friend"]=> int(30) ["all"]=> int(50) } ["1"]=> object(stdClass)#4 (2) { ["friend"]=> int(25) ["all"]=> int(25) } } Notice: Undefined offset: 3 in /in/0FV9u on line 6 NULL
Output for Array change keys
array(3) { ["3"]=> object(stdClass)#1 (2) { ["friend"]=> int(45) ["all"]=> int(100) } ["2"]=> object(stdClass)#3 (2) { ["friend"]=> int(30) ["all"]=> int(50) } ["1"]=> object(stdClass)#4 (2) { ["friend"]=> int(25) ["all"]=> int(25) } } Notice: Undefined offset: 3 in /in/0FV9u on line 6 NULL
Output for Lexical anon
array(3) { ["3"]=> object(stdClass)#1 (2) { ["friend"]=> int(45) ["all"]=> int(100) } ["2"]=> object(stdClass)#3 (2) { ["friend"]=> int(30) ["all"]=> int(50) } ["1"]=> object(stdClass)#4 (2) { ["friend"]=> int(25) ["all"]=> int(25) } } Notice: Undefined offset: 3 in /in/0FV9u on line 6 NULL

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