Answers for "select number of digit from string php"

PHP
6

php keep only numbers in string

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

Extract Numbers From a String in PHP

phpCopy<?php 
$string = 'Sarah has 4 dolls and 6 bunnies.';
$outputString = preg_replace('/[^0-9]/', '', $string);  
echo("The extracted numbers are: $outputString \n"); 
?>
Posted by: Guest on April-23-2021

Browse Popular Code Answers by Language