Answers for "getting only integer from a string php"

PHP
2

php get only numbers from string

$str = 'In My Cart : 11 items';
$int = (int) filter_var($str, FILTER_SANITIZE_NUMBER_INT);
Posted by: Guest on November-24-2020
0

get numbers from string php

phpCopy<?php 
$string = 'Sarah has 4 dolls and 6 bunnies.';
preg_match_all('!d+!', $string, $matches);
print_r($matches); 
?>
Posted by: Guest on April-23-2021

Code answers related to "getting only integer from a string php"

Browse Popular Code Answers by Language