如何在php中删除url中的%20

Current Code:

<?php

include('conn.php');
$sql = mysql_query("select min(news_id) 'min' from news");
$res = mysql_fetch_array($sql);
$qry=mysql_query("select * from news order by date(post_date) desc,priority desc ");
while($row1=mysql_fetch_array($qry)) {
    <p class='news_title'><a href='newsdetail.php?id=".urldecode($row1['news_heading'])."'>{$row1['news_heading']}</a></p>
}

?>

As I am passing the heading to the next page ...

The url in the next page is displaying like this

newsdetail.php?id=In%20front%20%20of%20the%20houses

I need to display like this:

newsdetail.php?id=In front of the houses

You can use urldecode to convert the URL string.

http://www.php.net/manual/en/function.urldecode.php

echo urldecode('newsdetail.php?id=In%20front%20%20of%20the%20houses');

will produce:

newsdetail.php?id=In front of the houses

You can't have raw spaces in the URL. If you try to put them in, then the browser will error correct and escape them for you.

You can't have spaces or special characters in the URL. If you try to put them in, then the browser will put %20 for spaces.

for clean url please replace the space or special charcters with hypen(-)

function cleanURL($textURL) {
  $URL = strtolower(preg_replace( array('/[^a-z0-9\- ]/i', '/[ \-]+/'), array('', '-'), $textURL));
            return $URL;
     }



while($row1=mysql_fetch_array($qry)) {
        <p class='news_title'><a href='newsdetail.php?id=".cleanURL($row1['news_heading'])."'>{$row1['news_heading']}</a></p>
    }

The output will be

newsdetail.php?id=In-front-of-the-houses

Think so this will help you