php获取字符串中数字

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_41120504/article/details/83069879
$list = "满10元减5元";
$patterns = "/\d+/";//结合正则获取字符串中数字
preg_match_all($patterns,$list,$arr);
print_r($arr);exit;
print_r($arr);exit;出来的结果是:

Array ( [0] => Array ( [0] => 10 [1] => 5 ) );

取值 $arr[ 0 ][ 0 ];     $arr[ 0 ][ 1 ];   

猜你喜欢

转载自blog.csdn.net/weixin_41120504/article/details/83069879
今日推荐