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.