xxxxxxxxxx
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 \n");
?>
xxxxxxxxxx
<?php
$str = '12jan';
$arr = preg_split('/(?<=[0-9])(?=[a-z]+)/i',$str);
print_r($arr);
xxxxxxxxxx
$s = "1,2,3,8,2";
$ints = array_map('intval', explode(',', $s ));
var_dump( $ints );