Answers for "php keep only numbers in string"

PHP
1

php keep only numbers in string

$str = preg_replace('/[^0-9.]+/', '', $str);
Posted by: Guest on February-25-2020
1

php get only numbers from string

$str = 'In My Cart : 11 items';
$int = (int) filter_var($str, FILTER_SANITIZE_NUMBER_INT);
Posted by: Guest on November-24-2020

Code answers related to "php keep only numbers in string"

Browse Popular Code Answers by Language