Answers for "php string only numbers and ."

PHP
6

php keep only numbers in string

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

get numbers from string php

phpCopy<?php 
$string = 'Sarah has 4 dolls and 6 bunnies.';
preg_match_all('!\d+!', $string, $matches);
print_r($matches); 
?>
Posted by: Guest on April-23-2021

Code answers related to "php string only numbers and ."

Browse Popular Code Answers by Language