Sunday, May 13, 2012

php function to extract the decimal number from the string

0
 Following function will return decimal  number values in array form from the string
function extract_numbers($string)
{
preg_match_all('/([\d]+)/', $string, $match);
return $match[0];
}
$decimal=extract_numbers('Samsung I9070 Galaxy S Advance');

print_r($decimal); 
Array ( [0] => 9070 ) 

No comments :

Post a Comment