Skip to content

Instantly share code, notes, and snippets.

@oropesa
Created June 26, 2020 12:07
Show Gist options
  • Save oropesa/9b784c7dcd873b583aee1cf5bd60f50e to your computer and use it in GitHub Desktop.
Save oropesa/9b784c7dcd873b583aee1cf5bd60f50e to your computer and use it in GitHub Desktop.
$str = 'In My Cart : 11 12 items';
preg_match_all('!\d+!', $str, $number);
// array( array( '11', '12' ) )
$str = '000031chacho87tio2loco';
preg_match_all('!\d+!', $str, $number);
// array( array( '000031', '87', '2' ) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment