我希望它喜欢删除特殊字符以及用破折号替换空格。 最佳答案 试试 str_repl-6ren">
gpt4 book ai didi

php - 将 URL 中的空格替换为破折号

转载 作者:IT王子 更新时间:2023-10-29 00:07:24 24 4
gpt4 key购买 nike

我设法替换了特殊字符,例如 : ;/etc 在我的 URL 中,但现在它又有空格了。这是我的代码:

<h3><a href="<?php echo (isset($row_getDisplay['post_id']) ? $row_getDisplay['post_id'] : ''); ?>_<?php echo str_replace(array(':', '\\', '/', '*'), ' ', urldecode($row_getDisplay['title'])); ?>.html" ><?php echo (isset($row_getDisplay['title']) ? $row_getDisplay['title'] : ''); ?></a></h3>

我希望它喜欢删除特殊字符以及用破折号替换空格。

最佳答案

试试 str_replace(' ', '-', $string);

关于php - 将 URL 中的空格替换为破折号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14600639/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com