3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $sections = array( array( 'name' => 'home', 'uri' => '/', 'title' => 'home'), array( 'name' => 'tech', 'uri' => '/tech', 'title' => 'ux/ui' ), array( 'name' => 'monetization', 'uri' => '/monetization', 'title' => 'monetization' ), array( 'name' => 'contact', 'uri' => '/contact', 'title' => 'contact', 'callToAction' => true, 'desktopTitle' => 'contact us' ), array( 'name' => 'blog', 'uri' => 'https://blog.marfeel.com/blog', 'title' => 'blog', 'external' => true), ); function callToActions($section) { return $section["callToAction"]; } function defaultSections($section) { return !$section["callToAction"]; } function buildSections ($sections) { $index = count($sections); while($index) { $section = $sections[--$index]; echo '<li> <a href="' . get_bloginfo('wpurl') . $section["uri"] . '">' . ($section["desktopTitle"]? ucfirst($section["desktopTitle"]): ucfirst($section["title"])) . '</a> </li>'; } } buildSections(array_filter($sections, callToActions)); //print_r(array_filter($sections, defaultSections));
based on MtH9c
Output for 7.2.0
Warning: Use of undefined constant callToActions - assumed 'callToActions' (this will throw an Error in a future version of PHP) in /in/F3AmD on line 32 Notice: Undefined index: callToAction in /in/F3AmD on line 12 Notice: Undefined index: callToAction in /in/F3AmD on line 12 Notice: Undefined index: callToAction in /in/F3AmD on line 12 Notice: Undefined index: callToAction in /in/F3AmD on line 12 Notice: Undefined offset: 0 in /in/F3AmD on line 24 Fatal error: Uncaught Error: Call to undefined function get_bloginfo() in /in/F3AmD:27 Stack trace: #0 /in/F3AmD(32): buildSections(Array) #1 {main} thrown in /in/F3AmD on line 27
Process exited with code 255.
Output for 7.0.0 - 7.1.10
Notice: Use of undefined constant callToActions - assumed 'callToActions' in /in/F3AmD on line 32 Notice: Undefined index: callToAction in /in/F3AmD on line 12 Notice: Undefined index: callToAction in /in/F3AmD on line 12 Notice: Undefined index: callToAction in /in/F3AmD on line 12 Notice: Undefined index: callToAction in /in/F3AmD on line 12 Notice: Undefined offset: 0 in /in/F3AmD on line 24 Fatal error: Uncaught Error: Call to undefined function get_bloginfo() in /in/F3AmD:27 Stack trace: #0 /in/F3AmD(32): buildSections(Array) #1 {main} thrown in /in/F3AmD on line 27
Process exited with code 255.
Output for 5.3.19 - 5.6.28
Notice: Use of undefined constant callToActions - assumed 'callToActions' in /in/F3AmD on line 32 Notice: Undefined index: callToAction in /in/F3AmD on line 12 Notice: Undefined index: callToAction in /in/F3AmD on line 12 Notice: Undefined index: callToAction in /in/F3AmD on line 12 Notice: Undefined index: callToAction in /in/F3AmD on line 12 Notice: Undefined offset: 0 in /in/F3AmD on line 24 Fatal error: Call to undefined function get_bloginfo() in /in/F3AmD on line 27
Process exited with code 255.