【问题标题】:Trying to remove all spaces from a field in WordPress试图从WordPress中的字段中删除所有空格
【发布时间】:2014-05-19 05:59:07
【问题描述】:

我在 WordPress 中有这行代码:

a href="http://domain.com/<?php echo $member['ut_member_name']; ?>"

我希望它取代没有任何空格的字段。

例如:http://domain.com/tomjones

该字段最初保存为“Tom Jones”。

知道我该怎么做吗...??

提前感谢。

【问题讨论】:

  • str_replace(" ","", $member['ut_member_name']);

标签: php wordpress concatenation


【解决方案1】:

这个怎么样? strtolower(str_replace(" ","", $member['ut_member_name']));

这将删除所有空格并将所有字符变为小写。

【讨论】:

    【解决方案2】:

    尝试 str_replace

    $member_name = str_replace(" ","", $member['ut_member_name']);
    

    【讨论】:

      【解决方案3】:

      您可以使用现有的 wordpress 功能。查看以下链接:

      http://codex.wordpress.org/Function_Reference/sanitize_title_with_dashes

      【讨论】:

        猜你喜欢
        • 2019-11-25
        • 1970-01-01
        • 2011-11-29
        • 1970-01-01
        • 1970-01-01
        • 2013-09-06
        • 2011-08-24
        • 2023-04-08
        相关资源
        最近更新 更多