Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

Extract Numbers From a String in PHP

phpCopy<?php 
$string = 'Sarah has 4 dolls and 6 bunnies.';
$int = (int) filter_var($string, FILTER_SANITIZE_NUMBER_INT);  
echo("The extracted numbers are: $int 
"); 
?> 
Source by www.delftstack.com #
 
PREVIOUS NEXT
Tagged: #Extract #Numbers #From #String #PHP
ADD COMMENT
Topic
Name
8+5 =