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);
}
?
轉載于:https://www.cnblogs.com/shcolo/p/5945192.html
總結
以上是生活随笔為你收集整理的PHP提取字符串中的数字的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: atitit。wondows 右键菜单的
- 下一篇: 用sort()方法随机打乱数组