- preg_match: documentation ( source)
- print_r: documentation ( source)
- preg_match_all: documentation ( source)
<?php
$str = 'In My Cart : 11 12 items';
preg_match_all('!\d+!', $str, $matches);
print_r($matches);
unset($matches);
$numbers = preg_match("/(\d+)/", $str, $matches)
? (int)$matches[1]
: NULL
;
print_r($matches);
unset($matches);