用下划线代替空格 [英] Replacing Spaces with Underscores
本文介绍了用下划线代替空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个PHP脚本,用户将输入一个名称,例如:Alex_Newton
,
I have a PHP Script that users will enter a name like: Alex_Newton
,
但是,某些用户将使用空格而不是下划线,所以我的问题是:
However, some users will use a space rather than an underscore, so my question is:
如何在PHP中使用下划线自动替换空格?
How do I auto-replace spaces with Underscores in PHP?
推荐答案
$name = str_replace(' ', '_', $name);
这篇关于用下划线代替空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文