Silverado_NL Posted March 21, 2007 Share Posted March 21, 2007 hi everybody, im currently trying to automate the process of cleaning up Telephone Fields. currently there are loads of fields in the database that contain both alphabetical characters and integer characters. is there a command to remove these alphabetical characters in the string???? my goal is to end up with only number and no other characters. if anybody has a clue, i'd sure like to know:) Thanks you in advance. Silverado Quote Link to comment Share on other sites More sharing options...
Iceman512 Posted March 21, 2007 Share Posted March 21, 2007 Hey Silverado, Try this: <?php $string = "This is the string that needs to have letters stripped from it, leaving: 1, 2, 3, 4, 5, ..."; $new_string = ereg_replace("[^A-Za-z]", "", $string ); ?> Hope it works, Iceman Quote Link to comment Share on other sites More sharing options...
Orio Posted March 21, 2007 Share Posted March 21, 2007 my goal is to end up with only number and no other characters. In that case you need to make a little change with Iceman's script: <?php $string = "123This is the string that needs to have letters stripped from it, leaving: 1, 2, 3, 4, 5, ..."; $new_string = ereg_replace("[^0-9]", "", $string ); //$new_string now holds 12312345 ?> Orio. 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.