Home > Net >  How can i show x amount of digits in php?
How can i show x amount of digits in php?

Time:09-27

i have this code tath cames form and RFID card ccffff10320d011899540002692a000002692ab7

i have a php system i need to show only the 14,15,16,17,18,19 digit (189954) is there a way of doing it? the 6 digit number al already store in my database so what the system does is if the number match is will give you asistance.

CodePudding user response:

Use substr()


$rfid = "ccffff10320d011899540002692a000002692ab7";

$a = substr($rfid, 14, 6); //189954

CodePudding user response:

You can get the value which you want, using the pattern I wrote for you.

If you want to get 6 digits:

preg_match('/([0-9a-z]{14})([0-9]{6})([0-9a-z]{20})/', $input_line, $output_array);

Output:

array(4
0   =>  ccffff10320d011899540002692a000002692ab7
1   =>  ccffff10320d01
2   =>  189954
3   =>  0002692a000002692ab7
)
  • Related