PHP - Extract numbers from a string


/ Published in: PHP
Save to your folder(s)

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


Copy this code and paste it in your HTML
  1. $str = 'In My Cart : 11 12 items';
  2. preg_match_all('!\d+!', $str, $matches);
  3. print_r($matches);

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.