Re: merge array

From: Date: Thu, 04 Mar 2004 02:58:02 +0000
Subject: Re: merge array
Groups: php.general 
Request: Send a blank email to php-general+get-179411@lists.php.net to get a copy of this message
Thanks for your help. "Lucian Cozma" <lcozma@interakt.ro> wrote in message news:<20040303084641.85541.qmail@pb1.pair.com>... > That should do it: > > <?php > $x = array(3,4,6,8); > $y = array(10,20,40,10); > $tmp = $x; > rsort($tmp); > $n = $tmp[0]; > > $newArr = array(); > $newArr = array_fill(0, $n-1, 0); > for($i=0;$i<count($x);$i++) { > $newArr[$x[$i]-1] = $y[$i]; > } > print_r($newArr); > ?> > > > "Max" <maxnamara@visitel.co.id> wrote in message > news:001201c400c8$78d1c890$2b8210ac@max... > Hello all, > > I have two arrays as follows: > > $x = array(3,4,6,8); > $y = array(10,20,40,10); > > I need these arrays could be merged with '0' in between. > > Result expected : > > $x = array(1,2,3,4,5,6,7,8); > $y = array(0,0,10,20,0,40,0,10); > > > Can anybody help me ? > Thanks in advance. > > > Max > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > >

« previous php.general (#179411) next »