Re: pushing array index

From: Date: Sat, 02 Feb 2002 00:38:01 +0000
Subject: Re: pushing array index
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-83227@lists.php.net to get a copy of this message
In article <006101c1ab7b$27ec01b0$9d0e533e@mazingerz>, dagi3d@dagi3d.net (Borja martín) wrote: > $img[3]["src"] = "img1"; > $img[6]["src"] = "img2"; > $img[9]["src"] = "img3"; > > and I would like to change the array index adding one to their values,but > only on the two last arrays, so that > I have: > > $img[3]["src"] = "img1"; > $img[7]["src"] = "img2"; > $img[10]["src"] = "img3"; > > the problem using the php functions like array splice to add a new array, is > that the keys are reindexed. unset() the array elements you don't want, assign the ones you do. Ex: $img[10]["src"]=$img[9]["src"]; unset($img[9]["src"]); -- CC

« previous php.general (#83227) next »