我得到了这个字符串:
if(条件A==值A-AND-条件B==值B-OR-条件C==值C)
我想要一个包含以下内容的数组:
array(3) {
[0]=>
string(...) "conditionA==valueA"
[1]=>
string(...) "conditionB==valueB"
[2]=>
string(...) "conditionC==valueC"
}
我目前正在使用这种模式:
preg_match("/^if\((.+)-(.+)\)/U", $current_step_data_exploded[0], $if_statements);
但它没有正确地满足第三个条件。有人可以帮助我吗?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
$string = "if(conditionA==valueA-AND-conditionB==valueB-OR-conditionC==valueC)"; $match = preg_match('/^if\((.+)\)$/', $string, $if); if ($match) { $conditions = preg_split('/\-(AND|OR)\-/', $if[1]); print_r($conditions); } else { echo "no matches."; }