Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

how to separate integer from string in php

 phpCopy<?php 
$string = 'Sarah has 4_dolls  8_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: #separate #integer #string #php
ADD COMMENT
Topic
Name
6+8 =