Return to Snippet

Revision: 64025
at June 28, 2013 00:52 by satie83


Initial Code
$str = 'In My Cart : 11 12 items';
preg_match_all('!\d+!', $str, $matches);
print_r($matches);

Initial URL
http://stackoverflow.com/questions/6278296/extract-numbers-from-a-string

Initial Description
I want to extract the numbers from a string that contains numbers and letters like

Initial Title
PHP - Extract numbers from a string

Initial Tags
regex, php

Initial Language
PHP