note 17650 deleted from function.array-push by jimw
| From: | jimw@php.net | Date: | Fri, 21 Dec 2001 00:41:37 +0000 |
| Subject: | note 17650 deleted from function.array-push by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-23671@lists.php.net to get a copy of this message | ||
function array_insert($source,$new,$pos){
array_splice($source,$pos,0,array($new));
return $source;
}
This does the exact same thing as Volker's array_insert.
It differs from Khan's array_intervene in that it does not padd
the end of the array with empty elements if $pos > count($source)
It also works correctly if $new is an array.
Try also :
$foo = array('one','four');
array_splice($foo,1,0,array('two','three'));
print_r($foo);
Ivan