note 13855 added to function.array-push.php

From: Date: Fri, 06 Jul 2001 10:30:17 +0000
Subject: note 13855 added to function.array-push.php
Groups: php.notes 
Request: Send a blank email to php-notes+get-15036@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; } ?> http://www.php.net/manual/en/function.array-push.php

« previous php.notes (#15036) next »