/**
* 拆分公式
* @
param $formula
* @
return array
*/
public function splitFormula($formula)
{
$formula = $t = str_replace(' ', '', $formula);
$formula = str_replace(['&&', '||'], [';', ';'], $formula);
$result = explode(';', $formula);
foreach ($result as $key => $value) {
while (true) {
$left = substr_count($value, '(');
$right = substr_count($value, ')');
if ($left === $right) break;
if ($left > $right) {
$value = substr_replace($value, '', strpos($value, '('), 1);
} else {
$value = substr_replace($value, '', strrpos($value, ')'), 1);
}
}
$result[$key] = $value;
}
return $result;
}