[PHP/MySQL] News System

Experienced Elementalist
Joined
Apr 30, 2011
Messages
241
Reaction score
23
How can I replace the spaces in my news titles with underscores (_) when being entered into the database, and then return them back as spaces when the title is echoed onto the page?

So:

Hello RaGEZONE would appear as Hello_RaGEZONE in the DB and as Hello RaGEZONE on the page.

Help is appreciated :)
 
what do you want it for?

supposing you are trying to create some kind of seo friendly permalink, you should simply store both..

and it's
PHP:
str_replace(" ", "_", $string);
or regex..


you should also remove(replace with their ascii counterpart) foreign signs and do strtolower..
 
Well, I'm doing it for my news system, I don't think that it's necessary to replace spaces with underscores, I guess it's a kind of OCD thing :')

Many thanks for the help :)
 
Well, I'm doing it for my news system, I don't think that it's necessary to replace spaces with underscores, I guess it's a kind of OCD thing :')

Many thanks for the help :)
I would remove the spaces and replace with underscores.
If you copy and paste a link say for example this into MSN:
Code:
http://www.site.com/news/php mysql news system
... it will break off the hyper link after "http://www.site.com/news/php", whereas if you replace spaces with underscores, it shouldn't break off the hyperlink.
 
Back