note 13855 deleted from function.array-push by jimw

From: Date: Fri, 21 Dec 2001 00:41:49 +0000
Subject: note 13855 deleted from function.array-push by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-23673@lists.php.net to get a copy of this message
here is a function in order to insert into a specific position of an array another variable. <? // Created on : 05/08/01, vjk // Description : Iserts the $input variable in $source_place position of the array: $source // Arguments : 1. $source : our initial array // 2. $input : the variable we want to insert // 3. $source_place : the position of the $source array to insert the previous variable // Output : $source (array) which has the $input in it // Extra comments : the function, functions recursivelly if $input has elements of arrays in it! function array_intervene( $source, $input, $source_place ) { for( $i=0; $i<($source_place-1); ++$i ) { $temp[] = $source[$i]; } $temp[] = $input; for( $i=($source_place-1); $i<=count($source); ++$i ) { $temp[] = $source[$i]; } return $temp; } ?>

« previous php.notes (#23673) next »