Re: Array key problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
*/


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux