I had a "eregi_replace" code before. Now updating the scripts with preg_match.. I was using this piece of the script to convert "Some Hotel Name.html" to look like "Some-Hotel-Name.html" with the code downbelow at some parts of the page. $space = ' '; $replace = '/-/'; $row[hotelname] = preg_replace($replace, $space, $row[hotelname]); $hotelname = preg_replace($replace, $space, $hotelname); $originalhotelname = preg_replace($space, $replace, $row[hotelname]); the var $space is basically a space.. But could not work it out.. what do I have to use as space ? $space ='/ /'; does not work. I get "Some//-//Hote//-//Name.html"
You can try this <?php $sefurl_separator = '-';// Search engine friendly URL separator $from = $row['hotelname']; $output = preg_replace('/([^a-z0-9\.]+)/i', $sefurl_separator, $from); echo $output;// This should be >>> Some-Hotel-Name.html ?> PHP: