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);
}
原文地址:https://www.cnblogs.com/shcolo/p/5945192.html