3v4l.org

run code in 300+ PHP versions simultaneously
<?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);

preferences:
41.47 ms | 402 KiB | 5 Q