Re: conditional question.
| From: | Chris Hayes | Date: | Wed, 26 Feb 2003 16:20:29 +0000 |
| Subject: | Re: conditional question. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-137256@lists.php.net to get a copy of this message | ||
At 17:10 26-2-03, you wrote:
I have a conditional that looks like this: if ((is_array($HTTP_POST_VARS['cart_quantity'])) && (is_array($HTTP_POST_VARS['products_id']))){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.//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"?