simonp Posted March 13, 2009 Share Posted March 13, 2009 I'm getting a sort code input from a text box but people are typing it in different ways eg: 40-21-20 40 21 20 How can I strip away hyphens and spaces from this string so I just get: 402120 Thanks Simon Link to comment https://forums.phpfreaks.com/topic/149283-solved-remove-spaces-andor-hyphens-from-a-string/ Share on other sites More sharing options...
lonewolf217 Posted March 13, 2009 Share Posted March 13, 2009 if you ALWAYS want to do this on the string, just use str_replace function $string = str_replace("-","",$string) $string = str_replace(" ","",$string) Link to comment https://forums.phpfreaks.com/topic/149283-solved-remove-spaces-andor-hyphens-from-a-string/#findComment-783960 Share on other sites More sharing options...
simonp Posted March 13, 2009 Author Share Posted March 13, 2009 Thanks lonewolf217! Link to comment https://forums.phpfreaks.com/topic/149283-solved-remove-spaces-andor-hyphens-from-a-string/#findComment-783968 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.