how to separate integer from string in php

Solutions on MaxInterview for how to separate integer from string in php by the best coders in the world

showing results for - "how to separate integer from string in php"
Fabio
16 Nov 2019
1 phpCopy<?php 
2$string = 'Sarah has 4_dolls  8_dolls and 6 bunnies.';
3$int = (int) filter_var($string, FILTER_SANITIZE_NUMBER_INT);  
4echo("The extracted numbers are: $int \n"); 
5?> 
6