Re: Array key problem
| From: | Jason Wong | Date: | Tue, 25 Feb 2003 17:09:48 +0000 |
| Subject: | Re: Array key problem | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-25914@lists.php.net to get a copy of this message | ||
On Wednesday 26 February 2003 00:37, Jorge Miguel Fonseca Martins wrote:
As this has nothing to do with databases you should post to the php-general
list.
> $test[]="a";
> $test[]="b";
>
> foreach ($test as $key=>$value)
> {
> if($key == "something") echo $key
> }
>
> even though theres no key in the array named "something" the code will
> print the key "0"
PHP is doing automatic type conversion for you. Use:
if ($key === "something" { ... }
instead. See manual for details.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
------------------------------------------
/*
If I were a grave-digger or even a hangman, there are some people I could
work for with a great deal of enjoyment.
-- Douglas Jerrold
*/