note 28725 deleted from function.array-push by philip
| From: | philip@php.net | Date: | Fri, 09 Oct 2009 16:40:08 +0000 |
| Subject: | note 28725 deleted from function.array-push by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-161598@lists.php.net to get a copy of this message | ||
Note Submitter: anton at titov dot net
----
For the note above: you can use array_splice function to insert a new value (or array) in the middle
of array, this will work like your code does:
<?php
$list = array(
"0" => "zero",
"1" => "one",
"2" => "two",
"3" => "three",
"4" => "four",
"5" => "five",
"6" => "six"
);
$value = "New Number Three";
$key = "3";
$new = array_splice($list, $key, 0, $value);
?>