php正则表达式提取字符串中数字的方法
php正则表达式提取字符串中数字的方法
整数:
function number($str) { return preg_replace('/\D/s', '', $str); } // echo 123456 echo number('Hello 123 world 456 !!');
支持小数:
function number($str) { return preg_replace('/[^\.0123456789]/s', '', $str); }
本文属原创,转载请注明原文:http://www.zhimatong.com/jiaocheng/941.html
为保证教程的实用性及扩大知识面覆盖,如果您有相似问题而未解决,可联系在线客服免费技术支持。
内容有用