O piu' in generale:
codice:
$numero = preg_replace('#\D+#', '', $stringa);