I have a conditional that looks like this:
if ((is_array($HTTP_POST_VARS['cart_quantity'])) && (is_array($HTTP_POST_VARS['products_id']))){
//do stuff
}
The evaluation returns false. What makes this confusing is just before this block, for debugging purposes, I have the following:
echo $HTTP_POST_VARS['cart_quantity'];
echo $HTTP_POST_VARS['products_id'];
Both of them return the string "Array", indicating to me that they are arrays. Now, if they're both arrays, and the conditional is checking to see if they're both arrays, wouldn't it make sense that it should evaluate to "true"?
My first reflex was to check the user-annotated manual and the last note seems to fit just fine to your problem:
----------------------------------------
syncro at outgun dot com
30-Jan-2003 10:16
I have noticed that is_array() acts a bit weird when the argument is an expression, rather than a variable. Working with a multilevel nested array, is_array($bigArray[$part]) does not return what it should, but $column=$bigArray[$part]; and then is_array($column) does the job fine...
It looks like this might happen with other is_* functions as well.
----------------------------------------
(from http://nl.php.net/manual/nl/function.is-array.php)
I suggest to also try $column=&$bigArray[$part]; <--- note the added &, so the (sub)array does not need to be copied.
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php