PHP中如何将变量名下划线替换为逗号?
- 内容介绍
- 文章标签
- 相关推荐
本文共计394个文字,预计阅读时间需要2分钟。
三种方法替换下划线:
1. 使用 `str_replace` 函数: php $str=str_replace('_', '', $str);
2. 使用 `str_ireplace` 函数: php $str=str_ireplace('_', '', $str);
3. 使用 `preg_filter` 函数: php $str=preg_filter('/_/', '', $str);
3种方法:1、使用“str_replace("_",",",$str)”语句查找下划线,并将其替换为逗号;2、用“str_ireplace("_",",",$str)”语句;3、用“preg_filter("/_/",",",$str)”。
本教程操作环境:windows7系统、PHP7.1版、DELL G3电脑
php将下划线转为逗号的方法:查找字符串中的下划线,将其替换为逗号即可。
本文共计394个文字,预计阅读时间需要2分钟。
三种方法替换下划线:
1. 使用 `str_replace` 函数: php $str=str_replace('_', '', $str);
2. 使用 `str_ireplace` 函数: php $str=str_ireplace('_', '', $str);
3. 使用 `preg_filter` 函数: php $str=preg_filter('/_/', '', $str);
3种方法:1、使用“str_replace("_",",",$str)”语句查找下划线,并将其替换为逗号;2、用“str_ireplace("_",",",$str)”语句;3、用“preg_filter("/_/",",",$str)”。
本教程操作环境:windows7系统、PHP7.1版、DELL G3电脑
php将下划线转为逗号的方法:查找字符串中的下划线,将其替换为逗号即可。

