PHP truncates numbers and then compares them according to the following conditions:

Source: Internet
Author: User
PHP truncates numbers and then compares strings according to the following conditions:
TKPC11090987TKPC12098M9YTKMR120990U9TKMR11059E56

Requirements:
1. capture 5 consecutive digits after each TKPC and TKMR. (In this example, TKPC has, and TKMR has)
2. compare the truncated number with the following conditions to echo yes.
2.1 two numbers of TKPC. if one group is less than or equal to 11069, echo tkpc.
2.1 TKMR two groups of numbers, if one group is less than or equal to 10999, echo tkmr.


Thank you very much!
Please provide the complete code in detail.


Reply to discussion (solution)

  0,'TKMR' => 0,);foreach($m[1] as $k => $v){$num = $m[2][$k];if($v == 'TKPC' && $num <= 11069 || $v == 'TKMR' && $num <= 10999){$res[$v]++;}}if($res['TKPC']){echo 'TKPC';}if($res['TKMR']){echo 'TKMR';}}fn($str);

Running is not displayed ?...

String:
TKPC11090987TKPC12098M9YTKMR120990U9TKMR11059E56

Requirements:
1. capture 5 consecutive digits after each TKPC and TKMR. (In this example, TKPC has, and TKMR has)
2. compare the truncated number with the following conditions to echo yes.
2.1 two numbers of TKPC. if one group is less than or equal to 11069, echo tkpc.
2.1 TKMR two groups of numbers, if one group is less than or equal to 10999, echo tkmr.


Thank you very much!
Please provide the complete code in detail.



It is not displayed after running ..

I did not hit it, but it was not displayed. Thank you.

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.