Question: How to replace %20 characters in URL with a dash (-) when the information is coming from a MySQL db?

Code: href='details.php?listid=$record[listingid]&title=$record[title]

It currently reads:
http://www.mysite.com/details.php?listid=800&title=970%20South%20Bald%20Head%20Wynd

It should read:
http://www.mysite.com/details.php?listid=800&title=970-South-Bald-Head-Wynd

I want to keep the title words for SEO purpose unless you think it is useless??

Thank you - Merci Beaucoup – Muchas Gracias

Natasha ;)

Thanks for the link. I have been looking at it and tried different things on my site. It is complicated to say the least.
I was hoping for a simple PHP code for URL decoding (%20 "or space" to a dash).

$str = "%20";
$str2 = urldecode($str);
echo $str2;
-

Note, some browsers may change - to %20 automatically as long as it's in a link, and there's nothing you can do about it, AFAIK.

commented: Best advice - Great code idea - Thanks SCRU +1

You are SOOOOOO right. It is working great in Mozilla but not in IE. THANK YOU so much for your help.
One tiny question do you think exchanging %20 with dashes help with SEO?
Have a fantastic day.

You are SOOOOOO right. It is working great in Mozilla but not in IE. THANK YOU so much for your help.
One tiny question do you think exchanging %20 with dashes help with SEO?
Have a fantastic day.

I don't know that much about SEO.

go for str_replace() or str_ireplace()..it may help u out.

One tiny question do you think exchanging %20 with dashes help with SEO?
Have a fantastic day.

Most of the search engines out there treat dashes as spaces when indexing sites/urls. Hence a search for "order of phoenix" might just show you http://somesite.com/order-of-phoenix but not http://someothersite.com/order_of_phoenix

That being said, I ain't no expert on SEO, it's just something I heard a while back which I thought I should share. More information here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.