tags:

views:

59

answers:

2

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?

+1  A: 
$newarray = array();
foreach($oldarray as $key => $value) $newarray[':' . $key] = $value;
Amber
+2  A: 

the simplest way would probably be to build a new array:

$newArray = array();
foreach($array as $key => $value)
{
    $newArray[":" . $key] = $value;
}
Zenon