Re: Kick one of these darn elements out of my array, I aint having it!
| From: | Thomas Deliduka | Date: | Mon, 12 Mar 2001 18:40:26 +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-43515@lists.php.net to get a copy of this message | ||
On 3/12/2001 1:38 PM this was written:
> 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]
Only thing I can think of is a loop:
$temparray = array();
Reset($array);
while ($elem = current($array)) {
if ($elem != "2") {
$temparray[] = $elem
}
next($array);
}
$array = $temparray;
--
Thomas Deliduka
IT Manager
-------------------------
New Eve Media
The Solution To Your Internet Angst
http://www.neweve.com/