$string = "Test test total count 500000 bytes"; $string = preg_replace('#[^0-9]#','',strip_tags($string)); echo $string;