3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $itinerary = array (array('portName'=>'Day At Sea'), array('portName'=>'Moscow')); $badPorts = array('At Sea', 'Day At Sea', 'Cruising The Mediterranean Sea'); $image = ''; $index = 0; $image .= implode(',', array_reduce($itinerary, function ($result, $item) use ($badPorts, &$index){ if(!in_array($item['portName'], $badPorts)) $result[$index] = $item['portName']; $index++; return $result; }, array())); var_dump($image); $image2 = ''; array_walk($image2, function($item, $index) use(&$image, &$index, $badPorts){ if(!in_array($item['portName'], $badPorts)) $result[$index] = $item['portName']; $index++; }); var_dump($image2);
Output for 7.1.0
Fatal error: Cannot use lexical variable $index as a parameter name in /in/JIXWn on line 15
Process exited with code 255.
Output for 5.3.0 - 7.0.14
string(6) "Moscow" Warning: array_walk() expects parameter 1 to be array, string given in /in/JIXWn on line 18 string(0) ""
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/JIXWn on line 6
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION in /in/JIXWn on line 6
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/JIXWn on line 6
Process exited with code 255.