note 69600 added to function.array-merge
| From: | poison at osu1 dot php dot net | Date: | Tue, 12 Sep 2006 12:45:27 +0000 |
| Subject: | note 69600 added to function.array-merge | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-117058@lists.php.net to get a copy of this message | ||
You can use array_slice() in combination with array_merge() to insert values into an array like
this:
<?php
$test=range(0, 10);
$index=2;
$data="---here---";
$result=array_merge(array_slice($test, 0, $index), array($data), array_slice($test, $index));
var_dump($result);
?>
----
Server IP: 217.13.201.10
Probable Submitter: 84.162.233.152
----
Manual Page -- http://www.php.net/manual/en/function.array-merge.php
Edit -- https://master.php.net/note/edit/69600
Del: integrated -- https://master.php.net/note/delete/69600/integrated
Del: useless -- https://master.php.net/note/delete/69600/useless
Del: bad code -- https://master.php.net/note/delete/69600/bad+code
Del: spam -- https://master.php.net/note/delete/69600/spam
Del: non-english -- https://master.php.net/note/delete/69600/non-english
Del: in docs -- https://master.php.net/note/delete/69600/in+docs
Del: other reasons-- https://master.php.net/note/delete/69600
Reject -- https://master.php.net/note/reject/69600
Search -- https://master.php.net/manage/user-notes.php