Eddyon Posted February 2, 2007 Share Posted February 2, 2007 I know this may sound simple but I really do not know how to do it. I have a variable called $title that currently contains symbols such as quotes and question marks, however I would like to create a second variable eg. $title1 that would contain the string with just a-z and 0-9 in it. Thanks in advance for any help, Craig. Quote Link to comment Share on other sites More sharing options...
Orio Posted February 2, 2007 Share Posted February 2, 2007 Not sure, but give this a try- $title1 = preg_replace("/[^a-z0-9]/i", $title); Orio. Quote Link to comment Share on other sites More sharing options...
Eddyon Posted February 2, 2007 Author Share Posted February 2, 2007 Cheers Orio, will give it a go. Quote Link to comment Share on other sites More sharing options...
ShogunWarrior Posted February 2, 2007 Share Posted February 2, 2007 Slight correction: $title1 = preg_replace("/[^a-z0-9]/i", "" , $title); Quote Link to comment Share on other sites More sharing options...
Orio Posted February 2, 2007 Share Posted February 2, 2007 lol I forgot the replacement part At least I got the regular expression part right, I am trying to learn Orio. Quote Link to comment Share on other sites More sharing options...
Eddyon Posted February 2, 2007 Author Share Posted February 2, 2007 Yep was just about to say with a little modifying it worked: $title1= preg_replace ("/[^a-z0-9+]/","",$title); Cheers for the help Orio and Shogun 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.