Just wanted to add a new parameter in the front of my array with array_unshift, but: If I do it like usual, it has an numeric index. How can I decline the index, e.g. something like that…
<?php
$queue = array("a", "B");
array_unshift($queue, "front" => "hello" ); //Not working, this is my question ;)
?>
The array would then look like
Array {
front => hello
0 => a
1 => B
}
Looks like array_unshift cannot do what you want. Try this:
This gives the result you want.
Array ( [front] => hello [0] => a [1] => b )