note 110255 added to function.array-shift
| From: | AleksandrMakov | Date: | Fri, 05 Oct 2012 08:35:26 +0000 |
| Subject: | note 110255 added to function.array-shift | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-191141@lists.php.net to get a copy of this message | ||
Many languages make
splice method capable of inserting data.
Here'a little function that I use for that:
<?php
function array_insert(&$array, $value, $index)
{
return $array = array_merge(array_splice($array, max(0, $index - 1)), array($value), $array);
}
?>
----
Server IP: 69.147.83.199
Probable Submitter: 80.235.87.101
----
Manual Page -- http://www.php.net/manual/en/function.array-shift.php
Edit -- https://master.php.net/note/edit/110255
Del: integrated -- https://master.php.net/note/delete/110255/integrated
Del: useless -- https://master.php.net/note/delete/110255/useless
Del: bad code -- https://master.php.net/note/delete/110255/bad+code
Del: spam -- https://master.php.net/note/delete/110255/spam
Del: non-english -- https://master.php.net/note/delete/110255/non-english
Del: in docs -- https://master.php.net/note/delete/110255/in+docs
Del: other reasons-- https://master.php.net/note/delete/110255
Reject -- https://master.php.net/note/reject/110255
Search -- https://master.php.net/manage/user-notes.php