4.3.3-RC1 => possible bug in in_array()?

This is a discussion on 4.3.3-RC1 => possible bug in in_array()? within the PHP General forums, part of the PHP Programming Forums category; -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi. I've just found weird thing about in_array() function. Platform: FreeBSD 5.1/...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-25-2003
Branko F. Gračnar
 
Posts: n/a
Default 4.3.3-RC1 => possible bug in in_array()?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi.

I've just found weird thing about in_array() function.

Platform: FreeBSD 5.1/PHP 4.3.3-RC1

Consider this code:

$this->_array_a and $this->_array_b ARE IDENTICAL

$data = array();
foreach ($this->_array_a as $key => $value) {
if (! in_array($key, $this->_array_b)
$data['added'][$key] = $this->_array_a[$key];
}

Therefore after execution $data should be empty.

But there is whole $this->_array_a in $data after execution...

The following code works ($data is empty after execution):
foreach ($this->_array_a as $key => $value) {
if (! isset($this->_array_b[$key]))
$data['added'][$key] = $this->_array_a[$key];
}

Why is this happening?

Brane
-----BEGIN PGP SIGNATURE-----

iD8DBQE/ISOGfiC/E+t8hPcRAll7AJ9EbH6FwwJC/vjsBNG3qMWvWVdmbQCggILs
UvLwPdDkKk2UrXxpPo6vF5M=
=OqAg
-----END PGP SIGNATURE-----

Reply With Quote
  #2 (permalink)  
Old 07-25-2003
Comex
 
Posts: n/a
Default Re: [PHP] 4.3.3-RC1 => possible bug in in_array()?

<3F21281C.4040103@webglobe.sk>
Marek Kilimajer:
> in_array searches for a value, you suply key. This will work as you
> expect:

array_key_exists searches for a key.


Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:14 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0