RE: [PHP] unset($array[value]) does not work?

From: Date: Wed, 12 Jun 2002 17:16:12 +0000
Subject: RE: [PHP] unset($array[value]) does not work?
Groups: php.general 
Request: Send a blank email to php-general+get-101771@lists.php.net to get a copy of this message
It is working. The last two tests you were running weren't actually the same, which was confusing your testing results. I've altered the code a little for ease of testing. It's included below. -----Original Message----- You will see that $unserialized['foo'] still exists! Can anyone explain me what I'm doing wrong? -------------------------- <? $array = array ( "foo" => "bar", "wom" => "bat" ); echo $array["foo"] . "<br>"; echo $array["wom"] . "<br>"; $serialized = serialize($array); echo $serialized . "<br>"; $unserialized = unserialize($serialized); echo $unserialized["foo"] . "<br>"; echo $unserialized["wom"] . "<br>"; echo "<hr>"; $keys = array_keys ($unserialized); echo $keys[0] . "<br>"; echo $keys[1] . "<br>"; echo "<hr>"; if (key_exists("foo", $unserialized)) { echo "foo exists!<br>"; } if (key_exists("wom", $unserialized)) { echo "wom exists!<br>"; } echo "<hr>"; unset ($unserialized['foo']); if (key_exists("foo", $unserialized)) { echo "foo exists!<br>"; } if (key_exists("wom", $unserialized)) { echo "wom exists!<br>"; } ?> **************************************************************************** This message is intended for the sole use of the individual and entity to whom it is addressed, and may contain information that is privileged, confidential and exempt from disclosure under applicable law. If you are not the intended addressee, nor authorized to receive for the intended addressee, you are hereby notified that you may not use, copy, disclose or distribute to anyone the message or any information contained in the message. If you have received this message in error, please immediately advise the sender by reply email and delete the message. Thank you very much.

« previous php.general (#101771) next »