Skip to content

Instantly share code, notes, and snippets.

@lerua83
Created November 13, 2013 13:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lerua83/7448987 to your computer and use it in GitHub Desktop.
Save lerua83/7448987 to your computer and use it in GitHub Desktop.
PHP - Extract numbers from a string: URL: http://stackoverflow.com/questions/6278296/extract-numbers-from-a-string I want to extract the numbers from a string that contains numbers and letters like
$str = 'In My Cart : 11 12 items';
preg_match_all('!\d+!', $str, $matches);
print_r($matches);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment