2025年02月13日 建站教程
php如何利用正则表达式排除字符串中的各种字符,只保留数字。下面web建站小编给大家详细介绍以下具体方法!
利用preg_replace()函数:
<?php header('content-type:text/html;charset=utf-8'); $str ='欢迎来到,web建站教程12345'; echo "原字符串:".$str."<br>"; $result = preg_replace("/[^0-9]/", "", $str); echo "过滤后字符串:".$result; ?>
本文链接:http://so.lmcjl.com/news/23061/