截取字符串,其后在拼装起来。给个思路各位

WBOY
Release: 2016-06-13 13:21:06
Original
910 people have browsed it

截取字符串,然后在拼装起来。给个思路各位。
三部处置室护理费+三部处置室护理治疗费+三部处置室化验费+(三部处置室床日总量+三部处置室入院人数*3+三部处置室出院人数*0.3) 把这上面的汉字先截取出来,我会在数据库中获取对应的费用用,然后在拼装好进行运算。我的处理是把运算符都替换为“,”然后以“,”分割这样的方式处理的。现在就是拼装怎么去拼装。

------解决方案--------------------

PHP code
$str = '三部处置室护理费+三部处置室护理治疗费+三部处置室化验费+(三部处置室床日总量+三部处置室入院人数*3+三部处置室出院人数*0.3)';
preg_match_all("|[^0-9*.+()]+|", $str, $matches);
$ar_txt = array_values($matches[0]);
$ar_val = array(1,2,3,4,5,6); //中文项目对应的价格数值
$str = str_replace($ar_txt, $ar_val, $str);
echo $str; //1+2+3+(4+5*3+6*0.3) <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template