Posted By

satie83 on 06/28/13


regex php numbers regular expressions strings

Versions (?)

PHP - Extract numbers from a string

 / Published in: PHP


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.