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_values(array_filter($sections, callToActions))); //print_r(array_filter($sections, defaultSections));
based on ahFSP
Output for 7.2.0 - 7.3.1
Warning: Use of undefined constant callToActions - assumed 'callToActions' (this will throw an Error in a future version of PHP) in /in/KsaEJ on line 36 Notice: Undefined index: callToAction in /in/KsaEJ on line 12 Notice: Undefined index: callToAction in /in/KsaEJ on line 12 Notice: Undefined index: callToAction in /in/KsaEJ on line 12 Notice: Undefined index: callToAction in /in/KsaEJ on line 12 1wololooooooArray ( [name] => contact [uri] => /contact [title] => contact [callToAction] => 1 [desktopTitle] => contact us ) <li> <a href="/contact">Contact us</a> </li>
Output for 5.3.19 - 5.6.38, hhvm-3.10.1 - 3.21.3, 7.0.0 - 7.1.25
Notice: Use of undefined constant callToActions - assumed 'callToActions' in /in/KsaEJ on line 36 Notice: Undefined index: callToAction in /in/KsaEJ on line 12 Notice: Undefined index: callToAction in /in/KsaEJ on line 12 Notice: Undefined index: callToAction in /in/KsaEJ on line 12 Notice: Undefined index: callToAction in /in/KsaEJ on line 12 1wololooooooArray ( [name] => contact [uri] => /contact [title] => contact [callToAction] => 1 [desktopTitle] => contact us ) <li> <a href="/contact">Contact us</a> </li>
Output for hhvm-3.22.0
Notice: Use of undefined constant callToActions - assumed 'callToActions' in /in/KsaEJ on line -1 Notice: Undefined index: callToAction in /in/KsaEJ on line -1 Notice: Undefined index: callToAction in /in/KsaEJ on line -1 Notice: Undefined index: callToAction in /in/KsaEJ on line -1 Notice: Undefined index: callToAction in /in/KsaEJ on line -1 1wololooooooArray ( [name] => contact [uri] => /contact [title] => contact [callToAction] => 1 [desktopTitle] => contact us ) <li> <a href="/contact">Contact us</a> </li>