3v4l.org

run code in 300+ PHP versions simultaneously
<?php function r($obj) { foreach ($obj as $name => $val) { $items = null; if (is_numeric($val)) { $type = 'numeric'; } elseif (is_string($val)) { $type = 'string'; } elseif (is_array($val)) { $type = 'array'; if (is_object($val[0])) { var_dump($val); die; $items = r($val[0]); } } echo PHP_EOL, '"', $name, '": {"type": "', $type, '", "required": true', ($items ? ', "items": {' . $items : '') ,'},'; } } $obj = json_decode('{"rating_imhonet":8.25, "rating_imdb":7.9, "genres":[ "Драмы", "Криминал" ], "description":"Фильм «Американская История Икс» (American History X) рассказывает об одном из лидеров неонацистской группировки Дереке Виньярде. Называя себя «Учениками апостолов», участники банды жестоко расправляются с теми, у кого не белый цвет кожи. Они крушат магазины латиносов, и готовы избить до смерти любого черного, который попадется им на пути. Решительный и смелый Дерек вызывает восхищение и уважение у своего младшего брата Денни, который стремится во всем ему подражать. Но после убийства двух чернокожих подростков, Дерек попадает в тюрьму. Там он начинает понимать всю ничтожность своих мировоззрений, и теперь, отсидев три года, ему предстоит вытащить брата из этой банды. Главные роли в кинофильме «Американская история Х» исполнили Эдвард Нортон («Иллюзионист») и Эдвард Ферлонг («Терминатор 2:Судный день»)./", "countries":[ "США" ], "poster":"http://st1.imhonet.ru/element/large/ca/f1/caf19b3c92fbcb70d4da439c82b4852d.jpg", "title_en":"American History X", "comments":10549, "similar":[ {"poster":"http://st1.imhonet.ru/element/large/47/4a/474a8e0218de9d3f62a771e8cf257b83.jpg", "title": "8 женщин"}, {"poster":"http://st1.imhonet.ru/element/large/ca/f1/caf19b3c92fbcb70d4da439c82b4852d.jpg", "title": "Название"} ], "directors":[ { "name_ru":"Тони Кэй", "photo":"http://st1.imhonet.ru/person/large/9a/33/9a331dcb850afeea0a3a1caafc193f5c.jpg", "id":75006, "name_en":"Tony Kaye" } ], "actors":[ { "name_ru":"Стэйси Кич", "photo":"http://st1.imhonet.ru/person/large/2b/22/2b22df0b43020a64f06e4e03a93dd6e2.jpg", "id":67145, "name_en":"Stacy Keach" }, { "name_ru":"Эдвард Ферлонг", "photo":"http://st1.imhonet.ru/person/large/30/3b/303b11042e2ca480604a5ee836306286.jpg", "id":67799, "name_en":"Edward Furlong" }, { "name_ru":"Кристофер Мастерсон", "photo":"http://st1.imhonet.ru/person/large/59/e3/59e3d230f4e9676746c305b00ff248ae.jpg", "id":69220, "name_en":"Christopher Masterson" }, { "name_ru":"Эдвард Нортон", "photo":"http://st1.imhonet.ru/person/large/40/52/4052ced1931eb204786b62b4c176190e.jpg", "id":70962, "name_en":"Edward Norton" }, { "name_ru":"Д\'Анджело Беверли", "photo":"http://st1.imhonet.ru/person/large/f2/1b/f21ba669096d07b50207f8cb59898953.jpg", "id":71356, "name_en":"D\'Angelo Beverly" }, { "name_ru":"Керам Малики-Санчес", "photo":"http://st1.imhonet.ru/person/large/79/c2/79c20426702775ec5e41514645a9e607.jpg", "id":75012, "name_en":"Keram Malicki-Sanchez" }, { "name_ru":"Алекс Сол", "photo":"http://st1.imhonet.ru/person/large/e8/70/e87004bcf08fea80d7374f20c2e059ed.jpg", "id":75016, "name_en":"Alex Sol" } ], "title_ru":"Американская История Икс", "year":1998, "duration":119, "id":187735}'); r($obj);
Output for 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.21, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
"rating_imhonet": {"type": "numeric", "required": true}, "rating_imdb": {"type": "numeric", "required": true}, "genres": {"type": "array", "required": true}, "description": {"type": "string", "required": true}, "countries": {"type": "array", "required": true}, "poster": {"type": "string", "required": true}, "title_en": {"type": "string", "required": true}, "comments": {"type": "numeric", "required": true},array(2) { [0]=> object(stdClass)#2 (2) { ["poster"]=> string(78) "http://st1.imhonet.ru/element/large/47/4a/474a8e0218de9d3f62a771e8cf257b83.jpg" ["title"]=> string(14) "8 женщин" } [1]=> object(stdClass)#3 (2) { ["poster"]=> string(78) "http://st1.imhonet.ru/element/large/ca/f1/caf19b3c92fbcb70d4da439c82b4852d.jpg" ["title"]=> string(16) "Название" } }
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6
Fatal error: Call to undefined function json_decode() in /in/OF6lF on line 24
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: json_decode() in /in/OF6lF on line 24
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
Fatal error: Call to undefined function: json_decode() in /in/OF6lF on line 24
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: json_decode() in /in/OF6lF on line 24

preferences:
218.68 ms | 401 KiB | 351 Q