正则表达式-字符串中取小数 如在“Your Current Quantity Discount\n\n 1 items @ $2.50 * 0% = $1.00\n\n\nTotal Discount: $2.20”取出2.50和1.00和2.20. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 $str = "Your Current Quantity Discount\n\n 1 items @ $2.50 * 0% = $1.00\n\n\nTotal Discount: $2.20”";preg_match_all("/([\d\.\$]+)/i",$str,$matches);var_dump($matches); <?php $str = "Your Current Quantity Discount\n\n 1 items @ $2.50 * 0% = $1.00\n\n\nTotal Discount: $2.20”";preg_match_all("/(\d+\.?\d+)/i",$str,$matches);echo '<pre>';var_dump($matches);echo '</pre>'?> <?php $str = "Your Current Quantity Discount\n\n 1 items @ $2.50 * 0% = $1.00\n\n\nTotal Discount: $2.20”";preg_match_all('/\$(\d+\.?\d+)/i',$str,$matches);echo '<pre>';var_dump($matches);echo '</pre>'?> [code=PHP$str = "Your Current Quantity Discount\n\n 1 items @ $2.50 * 0% = $1.00\n\n\nTotal Discount: $2.20”";preg_match_all("/(\d+\.\d+)/i",$str,$matches);var_dump($matches);][/code]只要数字。自己想出来了。不过还是谢谢热心的人 请问PHP连接oracle8i,怎么配置 centos 下使用 yum 安装php 5.2.17 无法使用mysql_connect、json_encode等函数 ubuntu下安装mysql出错. 做了一个下拉菜单为什么会影响下面的div? 登陆问题 php文件下载,下载的文件不能打开 真诚请教一个tcpdf的问题 php+mysql 清家当产 跪求帮助!在线等~ 是不是我的配置有问题?为什么逻辑与(&&)不起作用? 公司的短信平台出现问题,不知道从哪里下手,急!困惑! 正则表达式排除不管用啊,各位看看我这个写的有什么错误 新手请指点!
preg_match_all("/([\d\.\$]+)/i",$str,$matches);
var_dump($matches);
$str = "Your Current Quantity Discount\n\n 1 items @ $2.50 * 0% = $1.00\n\n\nTotal Discount: $2.20”";
preg_match_all("/(\d+\.\d+)/i",$str,$matches);
var_dump($matches);][/code]
只要数字。自己想出来了。不过还是谢谢热心的人