3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $json=<<<JSON { "players": [ { "name": "Moldova", "image": "/Images/Moldova.jpg", "roll_over_image": "tank.jpg" }, { "name": "Georgia", "image": "/Images/georgia.gif", "roll_over_image": "tank.jpg" }, { "name": "Belarus", "image": "/Images/Belarus.gif", "roll_over_image": "tank.jpg" }, { "name": "Armenia", "image": "/Images/armenia.png", "roll_over_image": "tank.jpg" }, { "name": "Kazahstan", "image": "/Images/kazahstan.gif", "roll_over_image": "tank.jpg" }, { "name": "Russia", "image": "/Images/russia.gif", "roll_over_image": "tank.jpg" }, { "name": "Ukraine", "image": "/Images/ukraine.png", "roll_over_image": "tank.jpg" }, { "name": "Uzbekistan", "image": "/Images/uzbekistan.gif", "roll_over_image": "tank.jpg" } ], "games": [ { "matches": [ { "player1id": 0, "player2id": 1, "winner": "*" }, { "player1id": 2, "player2id": 3, "winner": "*" }, { "player1id": 4, "player2id": 5, "winner": "*" }, { "player1id": 6, "player2id": 7, "winner": "*" }, { "player1id": 0, "player2id": 2, "winner": "*" }, { "player1id": 4, "player2id": 6, "winner": "*" }, { "player1id": 0, "player2id": 4, "winner": 4 } ] }, { "matches": [ { "player1id": 0, "player2id": 1, "winner": "*" }, { "player1id": 2, "player2id": 3, "winner": "*" }, { "player1id": 4, "player2id": 5, "winner": "*" }, { "player1id": 6, "player2id": 7, "winner": "*" }, { "player1id": 0, "player2id": 2, "winner": "*" }, { "player1id": 4, "player2id": 6, "winner": "*" }, { "player1id": 0, "player2id": 4, "winner": 0 } ] } ] } JSON; $tempArray=json_decode($json,true); echo "Original:\n"; print_r($tempArray); $matches=array("games"=>array(0=>array("matches"=>array(array("winner"=>"winner","player1id"=>"player1id","player2id"=>"player2id"))))); echo "\nTempered:\n"; print_r(array_merge_recursive($tempArray,$matches));
Output for 5.2.0 - 7.1.0
Original: Array ( [players] => Array ( [0] => Array ( [name] => Moldova [image] => /Images/Moldova.jpg [roll_over_image] => tank.jpg ) [1] => Array ( [name] => Georgia [image] => /Images/georgia.gif [roll_over_image] => tank.jpg ) [2] => Array ( [name] => Belarus [image] => /Images/Belarus.gif [roll_over_image] => tank.jpg ) [3] => Array ( [name] => Armenia [image] => /Images/armenia.png [roll_over_image] => tank.jpg ) [4] => Array ( [name] => Kazahstan [image] => /Images/kazahstan.gif [roll_over_image] => tank.jpg ) [5] => Array ( [name] => Russia [image] => /Images/russia.gif [roll_over_image] => tank.jpg ) [6] => Array ( [name] => Ukraine [image] => /Images/ukraine.png [roll_over_image] => tank.jpg ) [7] => Array ( [name] => Uzbekistan [image] => /Images/uzbekistan.gif [roll_over_image] => tank.jpg ) ) [games] => Array ( [0] => Array ( [matches] => Array ( [0] => Array ( [player1id] => 0 [player2id] => 1 [winner] => * ) [1] => Array ( [player1id] => 2 [player2id] => 3 [winner] => * ) [2] => Array ( [player1id] => 4 [player2id] => 5 [winner] => * ) [3] => Array ( [player1id] => 6 [player2id] => 7 [winner] => * ) [4] => Array ( [player1id] => 0 [player2id] => 2 [winner] => * ) [5] => Array ( [player1id] => 4 [player2id] => 6 [winner] => * ) [6] => Array ( [player1id] => 0 [player2id] => 4 [winner] => 4 ) ) ) [1] => Array ( [matches] => Array ( [0] => Array ( [player1id] => 0 [player2id] => 1 [winner] => * ) [1] => Array ( [player1id] => 2 [player2id] => 3 [winner] => * ) [2] => Array ( [player1id] => 4 [player2id] => 5 [winner] => * ) [3] => Array ( [player1id] => 6 [player2id] => 7 [winner] => * ) [4] => Array ( [player1id] => 0 [player2id] => 2 [winner] => * ) [5] => Array ( [player1id] => 4 [player2id] => 6 [winner] => * ) [6] => Array ( [player1id] => 0 [player2id] => 4 [winner] => 0 ) ) ) ) ) Tempered: Array ( [players] => Array ( [0] => Array ( [name] => Moldova [image] => /Images/Moldova.jpg [roll_over_image] => tank.jpg ) [1] => Array ( [name] => Georgia [image] => /Images/georgia.gif [roll_over_image] => tank.jpg ) [2] => Array ( [name] => Belarus [image] => /Images/Belarus.gif [roll_over_image] => tank.jpg ) [3] => Array ( [name] => Armenia [image] => /Images/armenia.png [roll_over_image] => tank.jpg ) [4] => Array ( [name] => Kazahstan [image] => /Images/kazahstan.gif [roll_over_image] => tank.jpg ) [5] => Array ( [name] => Russia [image] => /Images/russia.gif [roll_over_image] => tank.jpg ) [6] => Array ( [name] => Ukraine [image] => /Images/ukraine.png [roll_over_image] => tank.jpg ) [7] => Array ( [name] => Uzbekistan [image] => /Images/uzbekistan.gif [roll_over_image] => tank.jpg ) ) [games] => Array ( [0] => Array ( [matches] => Array ( [0] => Array ( [player1id] => 0 [player2id] => 1 [winner] => * ) [1] => Array ( [player1id] => 2 [player2id] => 3 [winner] => * ) [2] => Array ( [player1id] => 4 [player2id] => 5 [winner] => * ) [3] => Array ( [player1id] => 6 [player2id] => 7 [winner] => * ) [4] => Array ( [player1id] => 0 [player2id] => 2 [winner] => * ) [5] => Array ( [player1id] => 4 [player2id] => 6 [winner] => * ) [6] => Array ( [player1id] => 0 [player2id] => 4 [winner] => 4 ) ) ) [1] => Array ( [matches] => Array ( [0] => Array ( [player1id] => 0 [player2id] => 1 [winner] => * ) [1] => Array ( [player1id] => 2 [player2id] => 3 [winner] => * ) [2] => Array ( [player1id] => 4 [player2id] => 5 [winner] => * ) [3] => Array ( [player1id] => 6 [player2id] => 7 [winner] => * ) [4] => Array ( [player1id] => 0 [player2id] => 2 [winner] => * ) [5] => Array ( [player1id] => 4 [player2id] => 6 [winner] => * ) [6] => Array ( [player1id] => 0 [player2id] => 4 [winner] => 0 ) ) ) [2] => Array ( [matches] => Array ( [0] => Array ( [winner] => winner [player1id] => player1id [player2id] => player2id ) ) ) ) )
Output for 5.0.0 - 5.1.1, 5.1.3 - 5.1.6
Fatal error: Call to undefined function json_decode() in /in/fZfH8 on line 128
Process exited with code 255.
Output for 5.1.2
Fatal error: Call to undefined function json_decode() in /in/fZfH8 on line 129
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: json_decode() in /in/fZfH8 on line 128
Process exited with code 255.
Output for 4.3.2 - 4.4.1, 4.4.3 - 4.4.4
Fatal error: Call to undefined function: json_decode() in /in/fZfH8 on line 128
Process exited with code 255.
Output for 4.4.2
Fatal error: Call to undefined function: json_decode() in /in/fZfH8 on line 129
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: json_decode() in /in/fZfH8 on line 128