| simple in array question
|
tec4

msg:4421214 | 4:41 am on Feb 24, 2012 (gmt 0) | No idea why this is not working for me...perhaps i'm just super tired and my logic is off but is driving me crazy! lol Have a simple array, like:
$ret_array = Array ( [97381816989] => 1 [97381821414] => 1 [97381821534] => 1 [97381823199] => 1 )
and I try to check to see if the number 78 is in the array (which it should not be), like:
if (!in_array(78,$ret_array)) { echo "NOT in array"; } else { echo "IS in array"; }
The result is "Is in array" when I run this..also tried replacing the numeric 78 with a string like "word" and it still echos "IS in array" - am I overlooking something? lol Thanks for the help!
|
enigma1

msg:4421278 | 11:13 am on Feb 24, 2012 (gmt 0) | use the 3rd parameter for a strict check and see if it works in_array(78,$ret_array, true)
|
g1smd

msg:4421279 | 11:28 am on Feb 24, 2012 (gmt 0) | Your example code seems to be missing punctuation between array elements.
|
penders

msg:4424278 | 8:19 pm on Mar 2, 2012 (gmt 0) | | Your example code seems to be missing punctuation between array elements. |
| The example (pseudo) code looks like the output from print_r()? (There shouldn't be square brackets around the array indices either) - but if this was executed as-is you'd get a fatal parse error, not "Is in array". Is this being run on a 64-bit system? 97381816989 is outside the 32-bit integer range, so this is not going to be preserved on a 32-bit system. Although I don't think this should affect the immediate in_array() problem?!
|
|
|