Justtechjobs.com Find a programming school near you






Online Campus Both


php-general | 2000071

Re: [PHP] using integers as array keys From: Alex Rice (alex <email protected>)
Date: 07/07/00

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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe <email protected>
For additional commands, e-mail: php-general-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>