php 正则表达式 字符串中提取带小数点的数字?

2024-11-30 11:47:12
推荐回答(1个)
回答1:

$regexp = '/(\d+)\.(\d+)/is';

-----------------

$total = "42.234 EUR 53.218 AUD CAD97.164 311.151 MYR 125.042 NZD GBP84.270 SGD60.227 USD134.400";
preg_match_all('/(\d+)\.(\d+)/is', $total, $arr);
var_export($arr);
array (
0 =>
array (
0 => '42.234',
1 => '53.218',
2 => '97.164',
3 => '311.151',
4 => '125.042',
5 => '84.270',
6 => '60.227',
7 => '134.400',
),
1 =>
array (
0 => '42',
1 => '53',
2 => '97',
3 => '311',
4 => '125',
5 => '84',
6 => '60',
7 => '134',
),
2 =>
array (
0 => '234',
1 => '218',
2 => '164',
3 => '151',
4 => '042',
5 => '270',
6 => '227',
7 => '400',
),