3v4l.org

run code in 300+ PHP versions simultaneously
<?php $obj = json_decode('{ "quiz": { "sport": { "q1": { "question": "Which one is correct team name in NBA?", "options": [ "New York Bulls", "Los Angeles Kings", "Golden State Warriros", "Huston Rocket" ], "answer": "Huston Rocket" } }, "maths": { "q1": { "question": "5 + 7 = ?", "options": [ "10", "11", "12", "13" ], "answer": "12" }, "q2": { "question": "12 - 8 = ?", "options": [ "1", "2", "3", "4" ], "answer": "4" } } } }'); var_dump($obj); foreach ($obj as $v) { var_dump($v); }
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.14
object(stdClass)#7 (1) { ["quiz"]=> object(stdClass)#3 (2) { ["sport"]=> object(stdClass)#2 (1) { ["q1"]=> object(stdClass)#1 (3) { ["question"]=> string(38) "Which one is correct team name in NBA?" ["options"]=> array(4) { [0]=> string(14) "New York Bulls" [1]=> string(17) "Los Angeles Kings" [2]=> string(21) "Golden State Warriros" [3]=> string(13) "Huston Rocket" } ["answer"]=> string(13) "Huston Rocket" } } ["maths"]=> object(stdClass)#5 (2) { ["q1"]=> object(stdClass)#4 (3) { ["question"]=> string(9) "5 + 7 = ?" ["options"]=> array(4) { [0]=> string(2) "10" [1]=> string(2) "11" [2]=> string(2) "12" [3]=> string(2) "13" } ["answer"]=> string(2) "12" } ["q2"]=> object(stdClass)#6 (3) { ["question"]=> string(10) "12 - 8 = ?" ["options"]=> array(4) { [0]=> string(1) "1" [1]=> string(1) "2" [2]=> string(1) "3" [3]=> string(1) "4" } ["answer"]=> string(1) "4" } } } } object(stdClass)#3 (2) { ["sport"]=> object(stdClass)#2 (1) { ["q1"]=> object(stdClass)#1 (3) { ["question"]=> string(38) "Which one is correct team name in NBA?" ["options"]=> array(4) { [0]=> string(14) "New York Bulls" [1]=> string(17) "Los Angeles Kings" [2]=> string(21) "Golden State Warriros" [3]=> string(13) "Huston Rocket" } ["answer"]=> string(13) "Huston Rocket" } } ["maths"]=> object(stdClass)#5 (2) { ["q1"]=> object(stdClass)#4 (3) { ["question"]=> string(9) "5 + 7 = ?" ["options"]=> array(4) { [0]=> string(2) "10" [1]=> string(2) "11" [2]=> string(2) "12" [3]=> string(2) "13" } ["answer"]=> string(2) "12" } ["q2"]=> object(stdClass)#6 (3) { ["question"]=> string(10) "12 - 8 = ?" ["options"]=> array(4) { [0]=> string(1) "1" [1]=> string(1) "2" [2]=> string(1) "3" [3]=> string(1) "4" } ["answer"]=> string(1) "4" } } }

preferences:
128.64 ms | 417 KiB | 5 Q