Ultimate way to find phone numbers in PHP string with preg_replace

前端 未结 4 1826
无人及你
无人及你 2020-12-21 21:35

working on a project right now where we have large amount of text strings that we must localize phone numbers and make them clickable for android phones.

The phone n

4条回答
  •  半阙折子戏
    2020-12-21 22:15

    Try the following:

    preg_match_all('/\+?[0-9][\d-\()-\s+]{5,12}[1-9]/', $text, $matches);
    

    or:

    preg_match_all('/(\+?[\d-\(\)\s]{8,20}[0-9]?\d)/', $text, $matches);
    

提交回复
热议问题