run code in 150+ php & hhvm versions
Bugs & Features
<?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 5.4.0 - 5.4.29
Parse error: syntax error, unexpected 't' (T_STRING) in /in/p5tqL on line 15
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected '[' in /in/p5tqL on line 3
Process exited with code 255.