From:             [EMAIL PROTECTED]
Operating system: ALL
PHP version:      4.0.6
PHP Bug Type:     Unknown/Other Function
Bug description:  isset on a associative array does not distinct if key exist

There's no good way to check weather a key exists in an associative
array.

The problem is that if the key exists, but the value is null, is treated
the
same as if the key doesn't exist. 

The only way I figure is to check: in_array("key", array_keys($array))
but this seams rather expensive.

(Compare: perl has an "exists" function ...)

Sample:

  $sample = array("a" => "a", "b" => NULL);


  print ":".isset($sample['a'])."<br>\n";
  print ":".isset($sample['b'])."<br>\n";
  print ":".isset($sample['c'])."<br>\n";

  print ":".in_array("a", array_keys($sample))."<br>\n";
  print ":".in_array("b", array_keys($sample))."<br>\n";
  print ":".in_array("c", array_keys($sample))."<br>\n";

-- 
Edit bug report at: http://bugs.php.net/?id=13874&edit=1


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to