How Do I Take Out Only Numbers From A PHP String?
Correct variant will be:
$string = "Hello! 123 How Are You? 456";
$int = intval(preg_replace('/[^0-9]+/', '', $string), 10);
You can use this method to select only digit present in your text
function returnDecimal($text) {
$tmp = "";
for($text as $key => $val) {
if($val >= 0 && $val <= 9){
$tmp .= $val
}
}
return $tmp;
}