简体   繁体   中英

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.

尝试:

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);

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM