Hi Guys,
I am wondoering how to replace whitespace with a dynamic striing to a hyphen(-)
For example, the end user might type, Red Curtains,
I need to translate this into red-curtains.html
please help.
Thanks
replace whitespace with a hyphen
Moderator: General Moderators
You want to manipulate string, take a look at the string functions of php at http://de3.php.net/manual/en/ref.strings.php
More specifically you can look into str_replace from volka's link.
Also, if you need, strtolower or not, here it is just incase.
Also, if you need, strtolower or not, here it is just incase.
Code: Select all
<?php
$string = "Red Curtains";
$newstring = str_replace(" ", "-", $string );
echo $newstring;
?>