3v4l.org

run code in 300+ PHP versions simultaneously
<?php $blocks = [ 'header' => ['html' => '<header>%s</header>'], 'body' => ['html' => '<div>%s</div>'], 'footer' => ['html' => '<footer>%s</footer>'] ]; $elems = [ ]; $json = json_decode('{"header":[{"type":"background","data":{"src":"https://s3-eu-west-1.amazonaws.com/ptfl/panorama/517e910005dd01e736000005.jpg"}},{"type":"title","data":[{"type":"link","data":{"text":"WeDo","href":"http://dev.dotoknow.com/project/view/517e8bcd05dd018f3b00000e"}}]}],"body":[{"type":"post","data":{"text":["DoToKnow is a project like any other. And alike many other projects it is an ongoing process of discussing, building, developing and fine-tuning. On this page we will keep you up to date on any news and features of DoToKnow.","We would like to ask you to stay on-topic within the posts. If you have any questions, have a look at our About or FAQ pages. If they don\'t provide you with the necessary information you can always contact us through feedback@dotoknow.com"],"project":"517e8bcd05dd018f3b00000e","post":0}}],"footer":[{"type":"tags","data":{"text":["DoToKnow","Official Project","News Channel","Developer blog"]}}]}'); $html = ''; foreach($json as $key => $block) { $html .= $blocks[$key]->html; } print $html;
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Warning: Attempt to read property "html" on array in /in/cokuT on line 21 Warning: Attempt to read property "html" on array in /in/cokuT on line 21 Warning: Attempt to read property "html" on array in /in/cokuT on line 21
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
Notice: Trying to get property 'html' of non-object in /in/cokuT on line 21 Notice: Trying to get property 'html' of non-object in /in/cokuT on line 21 Notice: Trying to get property 'html' of non-object in /in/cokuT on line 21
Output for 7.3.32 - 7.3.33
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.38, 7.0.0 - 7.0.33, 7.1.0 - 7.1.25
Notice: Trying to get property of non-object in /in/cokuT on line 21 Notice: Trying to get property of non-object in /in/cokuT on line 21 Notice: Trying to get property of non-object in /in/cokuT on line 21
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/cokuT on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/cokuT on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/cokuT on line 3
Process exited with code 255.

preferences:
257.05 ms | 401 KiB | 424 Q