PDA

View Full Version : PHP Help Please



ianhull
02-08-2007, 05:49 AM
I need to replace a string which contains whitespace to a hyphen.

I have had a look through the manual but cannot work it out.

example, a user may type Red Curtain, I need this to be replaced with red-curtain

Any help greatly appreciated.

TJ_Tigger
02-08-2007, 07:51 AM
PHP has a function str_replace() in your case it might look like this.

str_replace(" ", "-", "Red Curtain");

There is also a strtolower()

You can probably string it all together like this

echo strtolower(str_replace(" ", "-", "Red Curtain"));

HTH
Tigg

ianhull
02-08-2007, 09:24 AM
TJ, that is exactly what I needed,

Thanks

:yes

TJ_Tigger
02-08-2007, 09:46 AM
www.w3schools.com has a lot of great information on PHP and other web technologies.

Imagine Programming
07-11-2008, 12:14 PM
or PHP.net :) (http://php.net)