Php 如何将%20替换为url中的-
我是php新手。我的问题是,我想用Php 如何将%20替换为url中的-,php,Php,我是php新手。我的问题是,我想用-替换url中的%20 <?php $test1='exmple.com/dp/id/om%20Joan'; $test1=str_replace('%20','-',$test1); echo $test1; 结果: $cleanUrl = 'www.somesite.com/in-here/'; url\u decode($yourURL),它将恢复空格和特殊字符以进行解码。您能给我一个示例吗code@teeyo%20是一个空格,因此它将被解码
-
替换url中的%20
<?php
$test1='exmple.com/dp/id/om%20Joan';
$test1=str_replace('%20','-',$test1);
echo $test1;
结果:
$cleanUrl = 'www.somesite.com/in-here/';
url\u decode($yourURL)
,它将恢复空格和特殊字符以进行解码。您能给我一个示例吗code@teeyo%20
是一个空格,因此它将被解码为空格,-
将是%2D
您能确认您想将%20
转换为-
,而不是空格吗?您能提供更多上下文吗?
$myUrl = 'www.somesite.com/in here/';
$cleanUrl = str_replace('/\\s/', '-', $myUrl);
$cleanUrl = 'www.somesite.com/in-here/';