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); echo $index; while($index) { $section = $sections[--$index]; echo "wololoooooo"; print_r($section); echo '<li> <a href="'. $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 6iB9s
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/ahFSP on line 36 Notice: Undefined index: callToAction in /in/ahFSP on line 12 Notice: Undefined index: callToAction in /in/ahFSP on line 12 Notice: Undefined index: callToAction in /in/ahFSP on line 12 Notice: Undefined index: callToAction in /in/ahFSP on line 12 1 Notice: Undefined offset: 0 in /in/ahFSP on line 26 wololoooooo<li> <a href=""></a> </li>
Output for 5.3.19 - 7.1.10
Notice: Use of undefined constant callToActions - assumed 'callToActions' in /in/ahFSP on line 36 Notice: Undefined index: callToAction in /in/ahFSP on line 12 Notice: Undefined index: callToAction in /in/ahFSP on line 12 Notice: Undefined index: callToAction in /in/ahFSP on line 12 Notice: Undefined index: callToAction in /in/ahFSP on line 12 1 Notice: Undefined offset: 0 in /in/ahFSP on line 26 wololoooooo<li> <a href=""></a> </li>