原始字符串
ROUND(({NOPAY_COUNT} * ({TOTAL_BASIC_SALARY}/24)),2)
我想过滤'{'& '}'用'$'替换单词
ROUND(($NOPAY_COUNT * ($TOTAL_BASIC_SALARY/24)),2)
答案 0 :(得分:1)
您可以使用preg_replace()一次:
<?php
$string = 'ROUND(({NOPAY_COUNT} * ({TOTAL_BASIC_SALARY}/24)),2)';
$string = preg_replace("/{(.+?)}/", "\$$1", $string);
echo $string; //ROUND(($NOPAY_COUNT * ($TOTAL_BASIC_SALARY/24)),2)
答案 1 :(得分:0)
您可以使用javascript
两次:
preg_replace()
答案 2 :(得分:0)
$NOPAY_COUNT = 1;
$TOTAL_BASIC_SALARY = 1;
$str = "ROUND(({NOPAY_COUNT} * ({TOTAL_BASIC_SALARY}/24)),2);";
$str = str_replace("{", "$" , $str);
$str = str_replace("}", "" , $str);
eval("echo ".$str);