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. Link to comment https://forums.phpfreaks.com/topic/36831-solved-removing-symbols-from-string/ 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. Link to comment https://forums.phpfreaks.com/topic/36831-solved-removing-symbols-from-string/#findComment-175707 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. Link to comment https://forums.phpfreaks.com/topic/36831-solved-removing-symbols-from-string/#findComment-175708 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); Link to comment https://forums.phpfreaks.com/topic/36831-solved-removing-symbols-from-string/#findComment-175709 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. Link to comment https://forums.phpfreaks.com/topic/36831-solved-removing-symbols-from-string/#findComment-175711 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 Link to comment https://forums.phpfreaks.com/topic/36831-solved-removing-symbols-from-string/#findComment-175713 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.