我试图匹配数组值。我如何匹配以下代码?
$os = array("CATEGORY=OS", "SYSTEM_NAME like '%A001%'", "CATEGORY=DB");
if (in_array("CATEGORY", $os)) {
echo "Got it";
}
我需要匹配数组中的CATEGORY
我该怎么做?
修改2
where (CATEGORY = 'OS' AND SYSTEM_NAME like '%A001%' AND CATEGORY = 'DB' AND SYSTEM_NAME like '%A001%')
我有类似这样的问题,我需要在类别occrence之前将AND
替换为OR
预期输出
where (CATEGORY = 'OS' AND SYSTEM_NAME like '%A001%' OR CATEGORY = 'DB' AND SYSTEM_NAME like '%A001%')
答案 0 :(得分:1)
使用这个preg_grep()php函数
$os = array("CATEGORY=OS", "SYSTEM_NAME like '%A001%'", "CATEGORY=DB");
if (preg_grep("/CATEGORY/", $os)) {
echo "Got it";
}
有关详情,请参阅this