/ Published in: PHP

There seems to be no easy way to insert a key and value at the beginning of an array, as array_unset does not allow you to specify a key. This is not a very efficient way to do it, but it works.
Pretend the array is currently: array("a"=>"b", "c"=>"d") and you would like "x"=>"z" at the beginning....
The snippet will result in $array being: array("x"=>"z", "a"=>"b", "c"=>"d")
Pretend the array is currently: array("a"=>"b", "c"=>"d") and you would like "x"=>"z" at the beginning....
The snippet will result in $array being: array("x"=>"z", "a"=>"b", "c"=>"d")
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$array["x"] = "z";
Comments
