1<?php
2// beware: number_format also rounds
3
4$number = 1234.56;
5
6// english notation (default)
7$english_format_number = number_format($number);
8// 1,235
9
10// French notation
11$nombre_format_francais = number_format($number, 2, ',', ' ');
12// 1 234,56
13
14$number = 1234.5678;
15
16// english notation without thousands separator
17$english_format_number = number_format($number, 2, '.', '');
18// 1234.57
19
1
2<?php
3
4$number = 1234.56;
5
6// let's print the international format for the en_US locale
7setlocale(LC_MONETARY, 'en_US');
8echo money_format('%i', $number) . "\n";
9// USD 1,234.56
10
11// Italian national format with 2 decimals`
12setlocale(LC_MONETARY, 'it_IT');
13echo money_format('%.2n', $number) . "\n";
14// Eu 1.234,56
15
16// Using a negative number
17$number = -1234.5672;
18
19// US national format, using () for negative numbers
20// and 10 digits for left precision
21setlocale(LC_MONETARY, 'en_US');
22echo money_format('%(#10n', $number) . "\n";
23// ($ 1,234.57)
24
25// Similar format as above, adding the use of 2 digits of right
26// precision and '*' as a fill character
27echo money_format('%=*(#10.2n', $number) . "\n";
28// ($********1,234.57)
29
30// Let's justify to the left, with 14 positions of width, 8 digits of
31// left precision, 2 of right precision, without the grouping character
32// and using the international format for the de_DE locale.
33setlocale(LC_MONETARY, 'de_DE');
34echo money_format('%=*^-14#8.2i', 1234.56) . "\n";
35// Eu 1234,56****
36
37// Let's add some blurb before and after the conversion specification
38setlocale(LC_MONETARY, 'en_GB');
39$fmt = 'The final value is %i (after a 10%% discount)';
40echo money_format($fmt, 1234.56) . "\n";
41// The final value is GBP 1,234.56 (after a 10% discount)
42
43?>
44
45
1<html>
2<head>
3<style>
4 #box
5 {
6 width:350px;
7 height:270px;
8 margin:0px auto;
9 border:2px solid black;
10 }
11 h2{
12 text-align: center;
13 }
14 table{
15 margin:0px auto;
16 }
17</style>
18</head>
19
20<body>
21
22<form align="center" action="currencyconvertor.php" method="post">
23
24<div id="box">
25<h2><center>Currency Converter</center></h2>
26<table>
27 <tr>
28 <td>
29 Enter Amount:<input type="text" name="amount"><br>
30 </td>
31</tr>
32<tr>
33<td>
34 <br><center>From:<select name='cur1'>
35 <option value="AUD">Australian Dollar(AUD)</option>
36 <option value="USD" selected>US Dollar(USD)</option>
37 </select>
38</td>
39</tr>
40<tr>
41 <td>
42 <br><center>To:<select name='cur2'>
43 <option value="INR" selected >Indian Rupee(INR)</option>
44 <option value="JPY">Japanese Yen(JPY)</option>
45 <option value="PHP">Philippine Peso(PHP)</option>
46
47 </select>
48</td>
49</tr>
50<tr>
51<td><center><br>
52<input type='submit' name='submit' value="CovertNow"></center>
53</td>
54</tr>
55</table>
56</form>
57<?php
58if(isset($_POST['submit'])){
59
60$amount = $_POST['amount'];
61$cur1 = $_POST['cur1'];
62$cur2 = $_POST['cur2'];
63
64if($cur1=="AUD" AND $cur2=="JPY"){
65echo "<center><b>Your Converted Amount is:</b><br></center>";
66echo "<center>" . $amount*82.463 . "</center>";
67}
68
69if($cur1=="AUD" AND $cur2=="INR"){
70echo "<center><b>Your Converted Amount is:</b><br></center>";
71echo "<center>" . $amount* 51.09 . "</center>";
72}
73
74if($cur1=="AUD" AND $cur2=="PHP"){
75echo "<center><b>Your Converted Amount is:</b><br></center>";
76echo "<center>" . $amount* 37.15 . "</center>";
77}
78
79if($cur1=="USD" AND $cur2=="JPY"){
80echo "<center><b>Your Converted Amount is:</b><br></center>";
81echo "<center>" . $amount* 109.49 . "</center>";
82}
83
84if($cur1=="USD" AND $cur2=="INR"){
85echo "<center><b>Your Converted Amount is:</b><br></center>";
86echo "<center>" . $amount* 67.83 . "</center>";
87}
88
89if($cur1=="USD" AND $cur2=="PHP"){
90echo "<center><b>Your Converted Amount is:</b><br></center>";
91echo "<center>" . $amount*49.32 . "</center>";
92}
93
94
95}
96
97?>
98
99</body>
100</html>