我有一个有1行的数组,并且该数组上的count()返回1.但是在下一个代码块中,count计算为0并且脚本死掉。知道这里发生了什么吗?
// Array below is returned from another function as $arr_values
Array
(
[80000018-1302638711] => Array
(
[Logistics] => -1028.46
[Sales & Marketing Expenses] => -400.00
[Taxes & Duties] => -10171.48
)
)
echo count($arr_values); // returns '1'
if(count($arr_values == 0)){ // We just demonstrated this is equal to '1'...
return false; // ... but this line still executes. WAT?
}
这可能很简单。任何帮助表示赞赏:)
答案 0 :(得分:2)
你的陈述说
count($arr_values == 0)
表示count(boolean)
其中0表示不是数组
你需要说count($arr_values) == 0