3v4l.org

run code in 300+ PHP versions simultaneously
<?php $phrase = "You should eat fruuits, vegetaaables, and fiiibeeer every day."; $healthy = array("fruits", "vegetables", "fiber"); $patterns = array_map(function($term){ $newterm = ""; for($x=0; $x<strlen($term); $x++) $newterm.= preg_escape($term[$x], "~")."+"; return "~(".$newterm.")~"; }); print_r($patterns); $yummy = array("pizza", "beer", "ice cream"); $newphrase = str_replace($healthy, $yummy, $phrase);
Output for 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Fatal error: Uncaught ArgumentCountError: array_map() expects at least 2 arguments, 1 given in /in/h9XLF:5 Stack trace: #0 /in/h9XLF(5): array_map(Object(Closure)) #1 {main} thrown in /in/h9XLF on line 5
Process exited with code 255.
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28
Fatal error: Uncaught ArgumentCountError: array_map() expects at least 2 arguments, 1 given in /in/h9XLF:9 Stack trace: #0 /in/h9XLF(9): array_map(Object(Closure)) #1 {main} thrown in /in/h9XLF on line 9
Process exited with code 255.
Output for 5.4.1 - 5.4.45, 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: array_map() expects at least 2 parameters, 1 given in /in/h9XLF on line 9

preferences:
180.63 ms | 403 KiB | 273 Q