Posted By

satie83 on 06/28/13


Tagged

regex php numbers regular expressions strings


Versions (?)

PHP - Extract numbers from a string


 / Published in: PHP
 

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

  1. $str = 'In My Cart : 11 12 items';
  2. preg_match_all('!\d+!', $str, $matches);
  3. print_r($matches);

Report this snippet  

You need to login to post a comment.