I would like to append a string to the values of a nested associative array in PHP.
The following is my array
$styles = array(
'Screen' => array(
"master.css",
"jquery-jvectormap-1.0.css"),
'handheld' => array("mobile.css")
);
Looping over it to change it in the following way fails.
foreach($media as $medium => $filename)
foreach($filenames as &$filename)
$filename = "/styles/".$filename;
Prefixing $medium with & just causes a syntax error.
This also fails.
function prepend($prefix,$string)
{
return $prefix.$string;
}
foreach($media as &$medium)
$medium = array_map(prepend("/styles"),$medium);
What is the simplest way to prefix "/styles/" to those css filenames given this data structure?