Re: Kick one of these darn elements out of my array, I aint having it!
| From: | David Robley | Date: | Mon, 12 Mar 2001 23:56:35 +0000 |
| Subject: | Re: Kick one of these darn elements out of my array, I aint having it! | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-43584@lists.php.net to get a copy of this message | ||
On Tue, 13 Mar 2001 05:08, Brandon Orther wrote:
> Hello,
>
> I want to take one element out of an array, is there a way to remove an
> element and have the array resorted so there isn't a blank spot where I
> remove the elements? Here is an example if the above text made no
> sense.
>
> Example: $array = Array("1", "2", "3", "4");
>
> So: $array[0] = 1, $array[1] = 2, $array[2] = 3, $array[3] = 4
>
> I want to kick $array[2] out and have $array[3] be moved to $array[2]
>
> Thank you,
From a quick look at the array functions, it seems like array_splice
might do the trick. It's PHP4 only, though.
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA