如何调用 preg_match 中的逗号分隔值
How to call commas separated values within preg_match
$values = 'apple,orange,banana,mango';
public static function likecheck( $data) {
if(preg_match("/( apple | orange | banana | mango )/i", $data) === 1) {
return true;
}
}
我希望我的 $values 在 preg_match 中被动态调用为 apple |橙色 |香蕉 |芒果
只需用逗号爆炸和 'glue' 以及内爆
$values = 'apple,orange,banana,mango';
$regexValues = implode(' | ', explode(',', $values));
if(preg_match("/ $regexValues /i", $data) === 1) {
return true;
}
$values = 'apple,orange,banana,mango';
public static function likecheck( $data) {
if(preg_match("/( apple | orange | banana | mango )/i", $data) === 1) {
return true;
}
}
我希望我的 $values 在 preg_match 中被动态调用为 apple |橙色 |香蕉 |芒果
只需用逗号爆炸和 'glue' 以及内爆
$values = 'apple,orange,banana,mango';
$regexValues = implode(' | ', explode(',', $values));
if(preg_match("/ $regexValues /i", $data) === 1) {
return true;
}