I also just discovered how to check for these keys with no value as isset() will
return false:
"bar");
$arr["foo"] = NULL;
print_r($arr); // you can see "foo" is still there
if (array_key_exists("foo", $arr))
{
echo("it's there!");
}
?>
bvr.
===
This is a good one I just learned last week -- unset the variable. That
is,
unset($Arr[2]);
or
unset($Arr['cyanide']);
from what I understand, the discovery of this easy way to do this was
accidental. See the second annotation of "array_splice()" in the PHP
manual here for the details:
array_splice() is the best!
thanks for the hint.
"Philip Olson" <[EMAIL PROTECTED]> wrote in message
Pine.BSF.4.10.10106252001180.61091-10@localhost">news:Pine.BSF.4.10.10106252001180.61091-10@localhost...
> Here's an example :
>
>
> $foo = array('a','b','c');
>
> unset($foo[1]
> http://php.net/manual/en/language.types.array.php
> there is written:
> "To change a certain value, just assign a new value to it. If you want to
> remove a key/value pair, you need to unset() it."
Damn, I looked for that and didn't find it =). Anyway, thanks for the heads
up. I was pretty sure
> > Hello,
> > how can I complete remove an item out of an array ?
> > I tried unset() as well as setting the value to null.
> >
> > Both result in the value being null but not the item being deleted.
>
> As far as I know, this is not possible. You can, however, create a new
> array
> and copy al
Here's an example :
a [2] => c
$bar = array('a','b','c');
$piece = array_splice ($bar, 1 ,1);
print_r($piece); // [0] => b
print_r($bar);// [0] => a [1] => c
?>
http://www.php.net/manual/function.array-splice.php
regards,
philip
On Mon, 25 Jun 2001, Bret R.
> Hello,
> how can I complete remove an item out of an array ?
> I tried unset() as well as setting the value to null.
>
> Both result in the value being null but not the item being deleted.
As far as I know, this is not possible. You can, however, create a new array
and copy all values except th
7 matches
Mail list logo