3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $fruits = array("Lemony & Fresh","Orange Twist","Apple Juice"); print_r($fruits); echo '<br />'; function name_base($key) { $name2 = str_replace(" ", "_", $key); $name3 = str_replace("&", "and", $name2); $name4 = strtolower($name3); echo $name4.'<br />'; return $name4; } echo '<br />'; $test = array_map('name_base', $fruits); $fruits_fixed = $test; echo '<br />'; print_r($fruits_fixed);
based on Jh5BI
Output for 4.3.0 - 7.2.0
Array ( [0] => Lemony & Fresh [1] => Orange Twist [2] => Apple Juice ) <br /><br />lemony_and_fresh<br />orange_twist<br />apple_juice<br /><br />Array ( [0] => lemony_and_fresh [1] => orange_twist [2] => apple_juice )