开发者

How to retrieve number using regex and preg_match in php

I am trying to retrieve the ten digit id number from a textarea.

e.g id no 1234567890

I was trying to use.

preg_match("/('/^[0-9]{10}/')/", $article, $tags);

But it does not work. I 开发者_开发技巧appreciate any help.

Thanks.


Try:

preg_match_all("/\d{10}/", $article, $tags);


preg_match('/[0-9]{10}/', $article, $tags);

Try that. Or if you have multiple IDs, you can use preg_match_all.

preg_match_all('/[0-9]{10}/', $article, $tags);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜