ballhogjoni Posted April 1, 2008 Share Posted April 1, 2008 How do i trim all the characters except for numbers? I assume I use the trim function. Ex: trim($string, "a-z,~!@#$%^&*()_+`[]{};':"<>?,./|\"); Am I missing something? Quote Link to comment Share on other sites More sharing options...
Caesar Posted April 1, 2008 Share Posted April 1, 2008 <?php $str = 'This is a string containing an account#455000455'; $clean = preg_replace('/[^0-9]+/','',$str); ?> Quote Link to comment Share on other sites More sharing options...
ballhogjoni Posted April 1, 2008 Author Share Posted April 1, 2008 thanks, what if I just want the 2 letters FC to be able to show and not be trimmed? How would I do that using your example? Quote Link to comment Share on other sites More sharing options...
Caesar Posted April 1, 2008 Share Posted April 1, 2008 <?php $clean = preg_replace('/[^FC0-9]+/','',$str); ?> ...Would allow both numbers and 'F' and 'C' 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.