我已经将复选框数据转换为一个字符串存储在我的数据库中。当我搜索in_array时,PHP爆炸函数只允许我检测第一个数组项。为什么?
但是,当我尝试使用爆炸函数将字符串转换回数组时,我无法在in_array中搜索除第一项外的任何内容。为什么?
$rolepref = explode(',', $roles);
print_r($rolepref) = [0] Strategy [1] Operations
if (in_array("Strategy", $rolepref) { echo "yes" } => Will echo yes
if (in_array("Operations", $rolepref) { echo "yes" } => Does not work
我在这里错过了什么?提前致谢!
你可以发布你想要检查的实际数组吗?和实际的代码。看起来你刚刚输入了它,因为它没有完成(在if语句中缺少右括号)。 –