socalnate Posted July 29, 2007 Share Posted July 29, 2007 $link = preg_replace(" ", "_", $link); I get an error Warning: preg_replace() [function.preg-replace]: Empty regular expression in So how do you represent whitespace in preg_replace? Nathan Quote Link to comment Share on other sites More sharing options...
Humpty Posted July 30, 2007 Share Posted July 30, 2007 I've not tested but a google search gave me these: ALL WHITESPACE NOT JUST THE SPACE CHARACTER: $after=preg_replace('/\s+/','',$before); ALL SPACES: $nospaces = str_replace(' ', '', $input); NEWLINE AND CARRIAGE RETURN: (added just in case you needed it too) str_replace("\n", '', $input); str_replace("\r", '', $input); EDIT: Decided to come back and identify the code as code (sorry) Quote Link to comment Share on other sites More sharing options...
socalnate Posted July 30, 2007 Author Share Posted July 30, 2007 Found an ereg_replace that worked perfect $link = ereg_replace("[ \r\t\n]+", "_", $link); $link = strtolower($game_name_link1); echo "<a href=\"http://www.mysite.com/portal/{$link}.html\" Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.