Re: [PHP4BETA] Problem with unset()
| From: | Ken Leshner | Date: | Wed, 28 Jul 1999 13:48:48 +0000 |
| Subject: | Re: [PHP4BETA] Problem with unset() | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-2904@lists.php.net to get a copy of this message | ||
How can I delete the key/value pairs from a global array, yet keep
its reference around so I can fill it up again?
--Ken
Zeev Suraski wrote:
>
> Once you unset() $MyArray(), it no longer exists, and the global reference
> doesn't apply to it anymore.
>
> Zeev
>
> At 03:13 28/07/99 , Ken Leshner wrote:
> >Hi guys,
> >
> >When I execute the following script, I get the message -
> >Warning: Variable passed to each() is not an array or object in ...
> >
> >Also try it after commenting out the unset() function.
> >
> >--Ken
> >
> ><?
> >function doArray()
> >{
> > global $MyArray;
> >
> > unset($MyArray);
> >
> > $MyArray[] = "abc";
> > $MyArray[] = 2;
> > $MyArray[] = "def";
> >
> > return;
> >}
> >
> > doArray();
> >?>
> >
> >
> >
> >Array Test
> >
> >
> >
> ><? while (list($key, $value) = each($MyArray)) printf("Key: %s, Value: %s
> >", $key, $value); ?>
> >--
> >PHP 4 Beta
>
> --
> Zeev Suraski <zeev@zend.com> http://www.zend.com/
> For a PGP public key, finger bourbon@netvision.net.il