如何在一长字符串中提取出所有数字?

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u014132947/article/details/83088567
1.定义正则
$ex = "/\d+/";

2.检测并存入数组

$arr = [];
txt = '';
preg_match_all($ex,$txt,$arr);





例:
txt = 'TC-比特币>BTC-比特币 </a><td class=market-cap data-usd=116666294488 data-cny=807815528757 data-btc=17324675>¥8,078亿<td><a href=/currencies/bitcoin/#markets target=_blank class=price data-usd=6734 data-cny=46628 data-btc=1>¥46,628</a><td>1,732万<td><a href=';

提取出的数字:
array (
  0 => 
  array (
    0 => '116666294488',
    1 => '807815528757',
    2 => '17324675',
    3 => '8',
    4 => '078',
    5 => '6734',
    6 => '46628',
    7 => '1',
    8 => '46',
    9 => '628',
    10 => '1',
    11 => '732',
  ),
)

猜你喜欢

转载自blog.csdn.net/u014132947/article/details/83088567
今日推荐