Im trying to move an array item to the top of the array using unshift but I get an unexpected result:
$all_people = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");
$new_value = $all_people['Ben'];
array_unshift($all_people, $new_value);
Here I expect to have an array where "Ben"=>"37
is the first item but I end up with this:
array(4) { [0]=> int(0) [1]=> string(5) "Peter" [2]=> string(3) "Ben" [3]=> string(3) "Joe" }
The first element is empty and "Ben" has not moved to the top which I thought was going to happen. Can someone help me out? Thanks!