Answers for "how to separate string from integer in php"

PHP
1

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 \n"); 
?>
Posted by: Guest on March-09-2021
0

explode php all values to int

$s = "1,2,3,8,2";
$ints = array_map('intval', explode(',', $s ));
var_dump( $ints );
Posted by: Guest on October-04-2021

Code answers related to "how to separate string from integer in php"

Browse Popular Code Answers by Language