Page 1 of 1

Extract word after a keyword

Posted: Mon Nov 01, 2010 2:20 am
by khamani
Hi,
I would like to extract the figures from a string. The string is MYR1,200. I want to extract the 1,200. Also the figures can be three e.g MYR800. So I want to extract the figure regardless of whether they are 3 or 4. kindly assist

Thanks

Re: Extract word after a keyword

Posted: Mon Nov 01, 2010 2:32 am
by s.dot

Code: Select all

$string = 'MYR5483';
echo substr($string, 3);

Re: Extract word after a keyword

Posted: Mon Nov 01, 2010 4:18 am
by VladSun

Code: Select all

preg_match('#\D+(\d+,?\d+)#', $input, $match)