Correction:
$new_array will contain:
$new_array[0]="b"
$ar contains the modified array with elements removed.
HTH
Garth
-Original Message-
From: Garth Sperring [mailto:[EMAIL PROTECTED]]
Sent: Friday, 3 January 2003 12:25 PM
To: '[EMAIL PROTECTED]'
Subject: R
On Thu, 2003-01-02 at 17:24, David Busby wrote:
> List,
> Suppose you have an array in PHP like
>
> $ar = array("a", "b", "c", "d", "e", "f", "g");
>
> Now say you want to remove the 3rd item
>
> unset($ar[2]);
>
> All good? Not really...the array doesn't get shifted down, how could one
>
Look at array_splice()
Something like $new_array=array_splice($ar,3,1) should return
$new_array[0]="a"
$new_array[1]="b"
$new_array[2]="d"
$new_array[3]="e"
$new_array[4]="f"
$new_array[5]="g"
Cheers
Garth
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
On Behalf Of
At 06:24 PM 1/2/03, David Busby wrote:
Suppose you have an array in PHP like
$ar = array("a", "b", "c", "d", "e", "f", "g");
Now say you want to remove the 3rd item
unset($ar[2]);
All good? Not really...the array doesn't get shifted down, how could one
pull that off (or should I spin th