I have an associative array. I need to add ':' to the start of all the keys.
What would be the fastest/simplest way of doing this?
And what would be the most efficient way to do this?
views:
59answers:
2
+1
A:
$newarray = array();
foreach($oldarray as $key => $value) $newarray[':' . $key] = $value;
Amber
2009-12-01 20:07:32
+2
A:
the simplest way would probably be to build a new array:
$newArray = array();
foreach($array as $key => $value)
{
$newArray[":" . $key] = $value;
}
Zenon
2009-12-01 20:07:55