Re: [PHP4BETA] Problem with unset()
| From: | Joey | Date: | Wed, 28 Jul 1999 12:41:49 +0000 |
| Subject: | Re: [PHP4BETA] Problem with unset() | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-2902@lists.php.net to get a copy of this message | ||
I tried this with most recent CVS.
If I leave unset() in, I get:
<html><head><title>Array Test</title></head>
<body>
<h1>Array Test</h1>
</body></html>
If I take unset out, I get:
<html><head><title>Array Test</title></head>
<body>
<h1>Array Test</h1>
Key: 0, Value: abc<br>Key: 1, Value: 2<br>Key: 2, Value:
def<br></body></html>
Works fine for me, but I don't quite understand the behavior
of unset() here...
--Joey Smith
On Tue, 27 Jul 1999, 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();
> ?>
>
> <html><head><title>Array Test</title></head>
> <body>
> <h1>Array Test</h1>
> <?
> while (list($key, $value) = each($MyArray))
> printf("Key: %s, Value: %s<br>", $key, $value);
> ?>
> </body></html>
>
> --
> PHP 4 Beta
>
>