[英]PHP in_array() function always true
Fixed! 固定! - Thanks to Barmar who's comments nudged me in the right direction.
-感谢Barmar的评论使我朝着正确的方向前进。 For what it is worth, the revised code is below.
为了它的价值,修改后的代码如下。 I wrapped everything in the in_array conditional instead of it being inside the loop.
我将所有内容包装在in_array条件中,而不是放在循环中。 Thanks for the help, I know I didn't supply much context.
感谢您的帮助,我知道我没有提供太多背景信息。
$skufirst = str_split($product_skucart);
if(!in_array($skufirst[0], $wildcards))
{
if($product_skuall != "")
{
$i=0;
foreach($product_skuall as $skuall)
{
if(strstr($product_skucart,$skuall))
{
$bprice=$base_amountall[$i];
$aprice=$additional_chargeall[$i];
}
$i++;
}
array_push($wildcards, $skufirst[0]);
}
$base_amt = $bprice;
$additional_charge = $aprice;
}
For each product you are always checking for the same condition: 对于每种产品,您始终要检查相同的条件:
$skufirst = str_split($product_skucart);
You never touch $product_skucart! 您永远不会碰到$ product_skucart!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.