I have an associate array with a bunch of arrays inside already.
I don't want to change the existing items' relative order(arrays already in the associative array), but, I'd like to insert new arrays into it with a random order(in between of the existing items). I tried multiple ways but none of them worked.
P.S.: I wrote a function which can insert array into associate array, but it always add array to the end of the associative array.
protected function array_push_assoc(&$array, $key, $value){
$array[$key] = $value;
return $array;
}
For example:
Original
array(
'apple'=>50,
'pear'=>10,
'banana'=>20
);
After:
array(
'apple'=>50, //<=== This remains the same relative order to pear and banana
'pear'=>10, //<=== This remains the same relative order to apple and banana
'something'=>15, //<===== this is randomly put in here.
'banana'=>20 //<=== This remains the same relative order to apple and pear
);