Forum Moderators: coopster
Example strings:
"$123.99 as a deposit"
"123.99 charged to card"
I am trying the following:
$elements=preg_split("/[\s,\£$]+/", $text);
If there is a currency symbol, the result will be contained in $elements[1] and if no currency symbol $elements[0].
To predetermine this I tried using the following:
$elements=preg_split("/[\s,\£$]+/", $text,PREG_SPLIT_NO_EMPTY);
Strangely, this returns the whole string in $elements[0]!
Is this a bug or am I doing something wrong? Is there a better way to achieve this? Is there any way I could cope with the Euro symbol or HTML special characters (£ etc..)
Thanks for your help
Shady
Eg: (untested!)
$text2 = ereg_replace("$", "", $text); $text3 = explode(".", $text2); Now call the values from the array that is $text3:
echo "Dollars = ".$text3[0];
echo "Cents = ".$text3[1] Any good?