- array_sum: documentation ( source)
- print_r: documentation ( source)
- preg_match_all: documentation ( source)
- intval: documentation ( source)
- preg_replace: documentation ( source)
<?php
$string = "Hello! 123 test this? 456. done? 100%";
$int = intval(preg_replace('/[^0-9]+/', '', $string), 10);
echo $int;
$str = 'In My Cart : 11 12 items';
preg_match_all('!\d+!', $str, $matches);
print_r(array_sum($matches));