这是我的代码:
$found = false;
foreach( $item_meta_data as $key => $meta ){
if( $meta['name'] == "Hardware" && $meta['display'] == "Free-Standing Hardware (max height = 14')" ) {
$found = true;
break;
}
}
$meta['display'] == "Free-Standing Hardware (max height = 14')"
意外失败...我用双引号将值引起来,因为值中有一个单引号。我还检查了值是字符串:
有人可以指出if
语句是否有问题吗?有趣的是,如果数组在$meta['display']
中具有更简单的值,则一切正常
PS:我也尝试了三元===比较式$meta['display'] === "Free-Standing Hardware (max height = 14')"
,但没有效果