- filter_var: 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);
$str = 'In My Cart : 11 items';
$int = filter_var($str, FILTER_SANITIZE_NUMBER_INT);
print_r($int);