[英]How can i read file and get 10 digit number only
我在nodepage
中有一个文件,其中有数据记录。 我只想提取10 digit
数字字段并将它们放入数组中。
我该如何实现? 我是PHP新手。
这是文件中的数据格式:
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将搜索$ string的所有行,并查找10位数长的数字\\d
{10}
,并确保在数字[\\s|$]
后没有空格或字符串结尾,以确保它不是11位数字数。
上面代码的输出:
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
)
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.