3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $path = null; $list = array('k1' => 'f1.txt', 'k2' => 'f2.txt', 'k3' => 'f3.txt', 'k4' => 'f4.txt'); //$mapping = array_map(function($item) use ($path) { return $path ? $path . $item : $item; }, $list); $pfxFilePath = 'pfxFilePath'; $passFilePath = 'passFilePath'; array_walk($list, function(&$item, $i) use ($pfxFilePath, $passFilePath) { $item.= $pfxFilePath . $passFilePath; }); var_dump($list);
based on ddJXt
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.2.6
array(4) { ["k1"]=> string(29) "f1.txtpfxFilePathpassFilePath" ["k2"]=> string(29) "f2.txtpfxFilePathpassFilePath" ["k3"]=> string(29) "f3.txtpfxFilePathpassFilePath" ["k4"]=> string(29) "f4.txtpfxFilePathpassFilePath" }