Search a 'blob' of text for numbers, and add them. ie:
Input from text field: "This is my blob of text. Today I went to the store and bought shoes for $50.00 and a sandwich for $7.75."
Output from script: "You spent $57.75!"
Obviously there could be some potential issues. A) what if the user doesn't enter a . to separate dollars and cents? You could come up with $5,775 for the above example.
Looking for some help, the whole / \ ^ 30z;nb 034485 of PHP gets aggravating to someone who is used to C languages clean syntax. I've been using something like the following just to try and find a number, let alone get the various values, sort out dollars/cents and add them. Not to mention this should be able to be done for more than one number in the string.
Code: Select all
$message = $HTTP_POST_VARS['message'];
preg_match(/ stuffthathastobewrong /, $message, $match);
echo "The number in the string is " . $match[1];
.t2h