How To Strip Numbers From String

RegisterLogin
How To Strip Numbers From String
Post Description: Need To Know About Striping Number From A String In A Script Using Php And Mysql Database
Tags: How, To, Strip, Numbers, From, String
This Post Was Posted On Nov 16, 2009 By Sanders #2756
i have a script which requires me to remove all numberic characters from a string.

for example, lets say i have this string:

$foo = 'my phone number is: 213-555-1212';

so i want it to be changed to:
$foo = 'my phone number is: ';

as you can see, all the digits have been removed and only the alpah characters are left
Leave Your Comments
webune
#2825 1
try using this function to clean your string:

PHPCODE:
<?php
	# FUNCTION BY WWW.WEBUNE.COM
	function remove_numbers($string) {
  		$vowels = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0", " ");
  		$string = str_replace($vowels, '', $string);
  		return $string;
  	}
	$string='This string will have all numbers removed - 213 555 3930';
	echo remove_numbers($string);
?>
Nov 16, 2009 Reply Report abuse
©2011 Webune Forums - Sat Dec 24, 2011 6:01 pm
Powered by: Webune Forums V3