Branden Wagner Posted October 5, 2006 Share Posted October 5, 2006 OK, so this is just for fun... why? i have no clue...anyway what is the best way to do the arrays/variables for the conversionsthe USD is the only one that works correctly.. because of the associative array.to finish i just need to do the same to the rest of them, but i was hoping there was a better way to do this.any suggestions?[code]<? if(isset($_REQUEST['amount'])) { $amount = $_REQUEST['amount']; $to = $_REQUEST['to']; $from = $_REQUEST['from']; // US, Yen, Euro, British Pound, Peso $USD = array("USD" => "1","JPY" => "0.0085","EUR" => "1.27","GBP" => "1.87" ,"MXN" => "0.09"); $JPY = array("117.50","1","150.0","221.52","10.76"); $EUR = array("0.79","0.0067","1","1.48","0.07"); $GBP = array("0.53","0.0045","0.68","1","0.05"); $MXN = array("10.98","0.0934","13.94","20.58","1"); if(is_numeric($amount)) { if($amount > 0) { $new = $amount * ${$from}[$to]; echo $new; } else { "Invalid Input: Positive numbers only"; } } else { echo "Invalid Input: use numeric characters only"; } } else { echo "Invalid Request: Please go back and try again"; }?>[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.