I assume this is an associative array?
It's a one-function call for an indexed array:
array_splice($the_array, $index_to_insert_at, 0, $the_thing_to_insert);
But this doesn't work for associative arrays, even if you got the offset of the key to insert after and used that as $index_to_insert_at-1, the key from the $thing_to_insert gets lost en route.
Hm... if the key being inserted matches one already present, do you want it to overwrite or not? If you do, do you want the key order to be adjusted, or not?