Truncates a string and then assembles it. Give me some ideas

Source: Internet
Author: User
Truncate the string and assemble it. Give me some ideas. Three treatment rooms nursing fee + three treatment rooms nursing treatment fee + three treatment rooms hosting fee + (total number of three treatment rooms per day + number of three treatment rooms admitted * 3 + number of discharged persons from three treatment rooms * 0.3) extract the Chinese character above, and I will get the corresponding fee in the database, and then compress it in the Assembly. My processing intercepts the string and then assembles it. Give me some ideas.
Three treatment rooms nursing fee + three treatment rooms nursing treatment fee + three treatment rooms hosting fee + (total number of three treatment rooms per day + number of three treatment rooms admitted * 3 + number of discharged persons from three treatment rooms * 0.3) extract the Chinese character above, and I will get the corresponding fee in the database, and then compress it in the Assembly. My processing is to replace all operators with "," and then separate them. Now, how can we assemble data.

------ Solution --------------------
PHP code
$ Str = 'three treatment rooms nursing fee + three treatment rooms nursing treatment fee + three treatment rooms hosting fee + (total daily amount of three treatment rooms + three treatment rooms admission * 3 + three treatment rooms discharged number of students * 0.3) '; preg_match_all ("| [^ 0-9 *. + ()] + | ", $ str, $ matches); $ ar_txt = array_values ($ matches [0]); $ ar_val = array (1, 2, 3, 4, 5, 6 ); // price value corresponding to the Chinese project $ str = str_replace ($ ar_txt, $ ar_val, $ str); echo $ str; // 1 + 2 + 3 + (4 + 5*3 + 6*0.3)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.