php - Add String to Array, Stay as Array -
i have 2 arrays:
$delete = array("delete" => "delete"); $folders = array("0" => "folder1","1" => "folder2"); $options = array_merge($delete, $folders);
how add "move " $folders , have $options stay array?
in drop down menu appear as:
delete move folder1 move folder2
if want add "move to" string every element of $folder array, try this:
$folders = array("0" => "folder1","1" => "folder2"); foreach($folders $key => $value) { $folders[$key] = 'move '.$value; } $options = array_merge($delete, $folders);
or (based on suggestion of @zamnuts)
$folders = array("0" => "folder1","1" => "folder2"); function moveto($n) { return 'move '.$n; } $folders = array_map("moveto", $folders); $options = array_merge($delete, $folders);
Comments
Post a Comment