php convert to currency code example
Example 1: format php currency
<?php
$number = 1234.56;
$english_format_number = number_format($number);
$nombre_format_francais = number_format($number, 2, ',', ' ');
$number = 1234.5678;
$english_format_number = number_format($number, 2, '.', '');
Example 2: php currency converter script
<html>
<head>
<style>
#box
{
width:350px;
height:270px;
margin:0px auto;
border:2px solid black;
}
h2{
text-align: center;
}
table{
margin:0px auto;
}
</style>
</head>
<body>
<form align="center" action="currencyconvertor.php" method="post">
<div id="box">
<h2><center>Currency Converter</center></h2>
<table>
<tr>
<td>
Enter Amount:<input type="text" name="amount"><br>
</td>
</tr>
<tr>
<td>
<br><center>From:<select name='cur1'>
<option value="AUD">Australian Dollar(AUD)</option>
<option value="USD" selected>US Dollar(USD)</option>
</select>
</td>
</tr>
<tr>
<td>
<br><center>To:<select name='cur2'>
<option value="INR" selected >Indian Rupee(INR)</option>
<option value="JPY">Japanese Yen(JPY)</option>
<option value="PHP">Philippine Peso(PHP)</option>
</select>
</td>
</tr>
<tr>
<td><center><br>
<input type='submit' name='submit' value="CovertNow"></center>
</td>
</tr>
</table>
</form>
<?php
if(isset($_POST['submit'])){
$amount = $_POST['amount'];
$cur1 = $_POST['cur1'];
$cur2 = $_POST['cur2'];
if($cur1=="AUD" AND $cur2=="JPY"){
echo "<center><b>Your Converted Amount is:</b><br></center>";
echo "<center>" . $amount*82.463 . "</center>";
}
if($cur1=="AUD" AND $cur2=="INR"){
echo "<center><b>Your Converted Amount is:</b><br></center>";
echo "<center>" . $amount* 51.09 . "</center>";
}
if($cur1=="AUD" AND $cur2=="PHP"){
echo "<center><b>Your Converted Amount is:</b><br></center>";
echo "<center>" . $amount* 37.15 . "</center>";
}
if($cur1=="USD" AND $cur2=="JPY"){
echo "<center><b>Your Converted Amount is:</b><br></center>";
echo "<center>" . $amount* 109.49 . "</center>";
}
if($cur1=="USD" AND $cur2=="INR"){
echo "<center><b>Your Converted Amount is:</b><br></center>";
echo "<center>" . $amount* 67.83 . "</center>";
}
if($cur1=="USD" AND $cur2=="PHP"){
echo "<center><b>Your Converted Amount is:</b><br></center>";
echo "<center>" . $amount*49.32 . "</center>";
}
}
?>
</body>
</html>