read the currency format

Posted by user485783 on Stack Overflow See other posts from Stack Overflow or by user485783
Published on 2011-01-05T12:28:51Z Indexed on 2011/01/06 0:54 UTC
Read the original article Hit count: 263

Filed under:
|
|

perhaps for some people this is easy, but I want to learn

There are 2 currency formats:

first currency format is 1,123,123.12 and this format may be like $1,123,123.12 or 1,123,123.12€ and

second currency format is 1.123.123,12 and this may be such $1.123.123,12 or 1.123.123,12€ so the difference is the placement of dots and commas

The above format will be

$this->value('one of the currency format insert here');

e.g. $this->value('$1,123,123.12'); or $this->value('1.123.123,12€');

that I want to know is the code if (first currency format) {use blah .. blah ..} elseif (second currency format) {use blah .. blah ..} else {/ / unsupported format}

so how the code to identify whether the entry is input the first currency format or second currency format?

thanks for the your pointers and ideas.

UPDATED:

I apologize for mistake in giving examples

When I tried to test the code I have a little confused because it seems not working

then I changed my prevoious parts, so that $value['amount'] it may be use

first currency format 1,123,123.12 and this format may be like $1,123,123.12 or 1,123,123.12€ and

second currency format 1.123.123,12 and this may be such $1.123.123,12 or 1.123.123,12€

then the value['amount'] will identify first with code like the following conditional

class curr_format {

private bla...bla..1
private bla...bla..2
var etc..

    public function curr_format ($bla...,$and_bla..) {

//then make conditional is here
if (first currency format) {//use blah .. blah ..} 
elseif (second currency format) {//use blah .. blah ..} 
else {/ / unsupported format}
//another codes..

at the end output as look like:

$identify = new curr_format();
echo $identify->curr_format($value['amount'],$else_statement);

© Stack Overflow or respective owner

Related posts about php

Related posts about format