logo       

Testing the existance of a value in an array: msg#00236

php.tcphp

Subject: Testing the existance of a value in an array

And I've used in_array, array_search and a quick custom function
(replicating in_array's functionality) and the behavior is consistent
between functions, but still is not what is desired (or logical).

PHP Version 4.3.8

I have an array called $filter:

Array
(
[0] => oid
[1] => app_edit_field_id
)

and the in_array is returning screwy values:

var_dump(in_array("oid",$filter));
bool(false)
var_dump(in_array("app_edit_field_id",$filter));
bool(true)

Compare to using a different filter array:
Array
(
[0] => oid
[1] => app_edit_field_id
[2] => oid
)

var_dump(in_array("oid",$filter));
bool(true)
var_dump(in_array("app_edit_field_id",$filter));
bool(false)
Lets try reversing the original array:
Array
(
[0] => app_edit_field_id
[1] => oid
)

var_dump(in_array("oid",$filter));
bool(true)
var_dump(in_array("app_edit_field_id",$filter));
bool(false)


Just to be sure, lets try another array containing different values:

Array
(
[0] => table_name
[1] => user_group
)
var_dump(in_array("table_name",$filter));
bool(false)
var_dump(in_array("user_group",$filter));
bool(true)

Does this make any sense to anyone?
This seems horribly illogical! Any input would be greatly appreciated.

Regards,
Benjamin Holmberg

---------------------------------------------------------------------
To unsubscribe, e-mail: talk-unsubscribe-4zcLI8jJc/rYtjvyW6yDsg@xxxxxxxxxxxxxxxx

Please read and follow the list guidelines:
http://www.tcphp.org/mailing_list/guidelines

The tcphp.org mailing list is sponsored by pajunas interactive, inc.




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise