note 25174 deleted from function.array-splice by kennyt

From: Date: Mon, 05 Jan 2004 02:39:59 +0000
Subject: note 25174 deleted from function.array-splice by kennyt
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-62925@lists.php.net to get a copy of this message
Note Submitter: jenner-@gmx.de ---- if you have to insert a $key => $val pair into an assoc. array (which doesn't allways make sense, but anyway) you can do something like: $arr = array("a" = > 1, "b" => 2, "c" => 3); $part1 = array_slice($arr, 0, 2); $part1["d"] = 4; $part2 = array_slice($arr, 2, count($arr)); $arr = array_merge($part1, part2); // $arr is now ["a" = > 1, "d" => 4, "c" => 3]

« previous php.notes (#62925) next »