There are two ways I can see to do this, you can use regular expressions (slower) or explode (faster, but less accurate). The advantage is that if someone removes spaces from the string the RegEx will still work while explode may suddenly break.
$src = "You can win tonight $200,000. Sign up now!";
function get_amount($from){
$src_tkns = explode(' ', $from);
foreach($src_tkns as $tkn){
if(substr($tkn, 0, 1)==='$'){
return (substr($tkn, -1, 1)=='.')?substr($tkn, 0, -1):$tkn;
}
}
return false;
}
function get_amount_regex($from){
$r = '/\$[-+]?[0-9]*(\,?[0-9]+)+/';
preg_match_all($r, $from, $res);
return is_array($res)?$res[0][0]:false;
}
print('Found: '.get_amount($src).'<br />');
print('Regex Found: '.get_amount_regex($src));
More about regular expressions and their usage on the PHP PCRE page at http://www.php.net/manual/en/book.pcre.php and on the Regular Expressions info site at http://www.regular-expressions.info/tutorial.html
One thing to note, the code above isn't optimal or all catching when it comes to errors. Make sure you perform tests with known valid and invalid strings before you use it for some type of critical work :)