Re: using integers as array keys
| From: | Alex Rice | Date: | Fri, 07 Jul 2000 22:37:24 +0000 |
| Subject: | Re: using integers as array keys | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-5472@lists.php.net to get a copy of this message | ||
Carroll: Thanks for the example. I stand corrected.
To the list: I apologize for the noise.
I don't know how I got so completely confused and worked up about this
issue. I must be a) thinking in Perl (@ vs %) and b) must have
actually been using $myarray[] instead of $myarray[$id], thus seeing
keys which I did not expect to be defined yet.
I've actually been using PHP, on and off, for a couple of years, if
you can believe it :-)
Thanks for not flaming me all to hell!
Alex
Carroll Barrett writes:
> Alex,
>
> I was curious how that would work, so I wrote the following
> script (using php4)
>
> function echoIsSet($sub) {
> global $myarray;
>
> if(isset($myarray[$sub]))
> echo "$sub is set<BR>";
> else
> echo "$sub is NOT set<BR>";
> }
>
> $myarray=array();
> $myarray[567]=1;
> $myarray[31416]=1;
> echoIsSet(0);
> echoIsSet(1);
> echoIsSet(567);
> echoIsSet(1000);
> echoIsSet(31416);
> echoIsSet(40000);
>
> with the following results.
>
> 0 is NOT set
> 1 is NOT set
> 567 is set
> 1000 is NOT set
> 31416 is set
> 40000 is NOT set
>
> This isn't what you want?
>
> Regards,
> Carroll Barrett