【问题标题】:Replace spaces with a Underscore in a URL [duplicate]用 URL 中的下划线替换空格 [重复]
【发布时间】:2023-03-04 11:55:02
【问题描述】:

用下划线替换<?= $gr->grp_name ?>中的空格

    <div class="groupinfo">
                    <a href="<?= base_url() ?>group/group_id/<?= $gr->grp_id ?>/<?= $gr->grp_name ?>">

【问题讨论】:

标签: php


【解决方案1】:

尝试使用str_replace 将空格替换为下划线

<div class="groupinfo">
<a href="<?= base_url() ?>group/group_id/<?= $gr->grp_id ?>/<?= str_replace(" ","_",$gr->grp_name) ?>">
</div>

【讨论】:

  • 请关闭研究不足的重复问题。 Stackoverflow 不需要在同一社区的其他地方已经解决的新页面。
【解决方案2】:

你可以使用 str_replace() 函数。

【讨论】:

  • 请关闭研究不足的重复问题。 Stackoverflow 不需要在同一社区的其他地方已经解决的新页面。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-07-12
  • 2020-02-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-14
相关资源
最近更新 更多