Apparently in 4.1.X this is true... I'd been running 4.0.6 for a long time (until 
4.1.2 was
released), and must have coded it in the earlier version. I stand corrected! :-)

A simple test to see if your version supports this:

$array = array();
$array[0] = "zero";
$array[1] = "one";
$array[2] = "two";
$array[3] = "three";


foreach ($array as $key=>$value) {
        echo $key." = ".$value."<BR>";

If you're running an older version, it should output:
0 = zero
1 =
2 = two
3 = three

Versions 4.1.X+ should completely remove key 1.


# Nathan

----- Original Message -----
From: "Lars Torben Wilson" <[EMAIL PROTECTED]>
To: "Nathan" <[EMAIL PROTECTED]>
Sent: Friday, April 26, 2002 1:46 PM
Subject: Re: [PHP] Array function to delete

On Thu, 2002-04-25 at 12:34, Nathan wrote:
> No. :-)
> What I've had to do is add a dummy value, unset($array[4]) and then array_pop the 
>dummy value off
> the array to get it out of there completely. The reason: unset will only remove 
>$array[4]'s value,
> not the key.
> There are plenty of other ways I'm sure, but simply unsetting has really messed me 
>up on occasion.
> I'll unset a value and then implode my array (say a list of numbers), and end up 
>with a string
> so:
> 1,233,642,,234,5632,
> Where I've unset the 4th and last keys. Which of course really messes up an explode.
> # Nathan

You need to upgrade. :) The above hasn't been true for a
least since 4.1.2 and perhaps earlier.

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to