submitted by:
PHP: extract numbers from string
Extract numbers from a string (remove all letters, symbols, and other characters.)
Using ereg_replace, we specify that numbers 0-9 should NOT be replaced, and therefore removing letters, symbols, and everything else.
code snippet:
<?php
// extract numbers from a string
// http://php.snippetdb.com
$string = "The 1. Quick and 2. Brown fox said 3. (!@*(#!@*";
$new_string = ereg_replace("[^0-9]", "", $string);
echo $new_string;
?>
sample output:
123



