I want to extract the digits from a string that contains numbers and letters like:
"In My Cart : 11 items"
I want to extract the nu
If you don't know which format the number is? int or floating, then use this :
$string = '$125.22'; $string2 = '$125'; preg_match_all('/(\d+.?\d+)/',$string,$matches); // $matches[1] = 125.22 preg_match_all('/(\d+.?\d+)/',$string2,$matches); // $matches[1] = 125