Say I have an associative array:
array(
"color" => "red",
"taste" => "sweet",
"season" => "summer"
);
and I want to introduce a new element into it:
"texture" => "bumpy"
behind the 2nd item but preserving all the array keys:
array(
"color" => "red",
"taste" => "sweet",
"texture" => "bumpy",
"season" => "summer"
);
is there a function to do that? array_splice()
won't cut it, it can work with numeric keys only.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…