I have a file in nodepage
where data record are available. I want to extract only the 10 digit
numeric fields and put them into an array.
How can I achieve this? I am new to PHP.
Here is the data format in file:
STD OBD500-450-0514SIPPOOLPLAN
15/05/16
Page 878
Product Type: SIP Trunk Channel Line Int
Bill Number
PO Number 0
Bill Date
18:38:41 7045693328 Vodafone-MUM 00:01:00 4 0.60 18:51:59 9819286096 Vodafone-MUM 00:00:22 2 0.30
18:41:56 9833329668 Vodafone-MUM 00:03:51 16 2.40 18:52:08 9822965734 Idea-MH 00:01:07 5 0.75
18:42:23 9075613876 Idea-MH 00:01:22 6 0.90 18:53:59 9822965734 Idea-MH 00:00:53 4 0.60
18:44:07 9403358204 BSNL-MH 00:00:43 3 0.45 18:54:30 8691955808 Idea-MUM 00:01:09 5 0.75
preg_match_all("/(\d{10})[\s|$]/", $string, $output);
var_dump($output);
Preg_match_all will search all lines of $string and look for numbers \\d
that is 10 digits long {10}
and make sure there is a space or end of string after the digits [\\s|$]
to make sure it's not a 11 digit number.
output of above code:
array(2
0=>array(8
0 => 7045693328
1 => 9819286096
2 => 9833329668
3 => 9822965734
4 => 9075613876
5 => 9822965734
6 => 9403358204
7 => 8691955808
)
1=>array(8
0 => 7045693328
1 => 9819286096
2 => 9833329668
3 => 9822965734
4 => 9075613876
5 => 9822965734
6 => 9403358204
7 => 8691955808
)
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.