note 15629 deleted from function.array-push by jimw
| From: | jimw@php.net | Date: | Fri, 21 Dec 2001 00:41:43 +0000 |
| Subject: | note 15629 deleted from function.array-push by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-23672@lists.php.net to get a copy of this message | ||
// insert a value at the specified position into an array
// Author: Volker Richter
function array_insert($source, $newvar, $source_place )
{
$elements=count($source);
if($source_place==0)
{
array_unshift($source,$newvar);
return $source;
}
if($source_place>$elements)
{
$source[]=$newvar;
return $source;
}
for($i=0;$i<$source_place;$i++)
$temp[]=$source[$i];
$temp[]=$newvar;
for($i=$source_place;$i<count($source);$i++)
$temp[]=$source[$i];
return $temp;
}