$form_block = "
";
// remove commas and spaces
trim($value1);
$valuetemp = preg_replace("/,/", "", $value1);
$value = preg_replace("/ /", "", $valuetemp);
// get the first character in the value to later check that it's not a letter
$check = substr($value, 0, 1);
// in case no number is entered, the page refreshes
if ($value == "") {
echo "Conversion Tool";
echo "This does a variety of conversions, such as centimeters to inches as so on. ";
echo "First, put a number in the box, then choose a calculation, then press the button at the bottom. ";
echo "Use a period . for decimal points. ";
echo " ";
echo "$form_block";
} else if (($check != "0") && ($check != "1") && ($check != "2") && ($check != "3") && ($check != "4") && ($check != "5") && ($check != "6") && ($check != "7") && ($check != "8") && ($check != "9") && ($check != ".") && ($check != "-")) {
// oddly the quotes were needed above around 0 etc for absolute values otherwise letters parsed through
echo "Conversion Tool";
echo "This does a variety of conversions, such as centimeters to inches as so on. ";
echo "First, put a number in the box, then choose a calculation, then press the button at the bottom. ";
echo "Use a period . for decimal points. It can't start with a letter. ";
echo " ";
echo "$form_block";
} else {
{
if ($value == 1) {
$plural = "";
} else
$plural = "s";
}
if ($convert == "celfar") {
$result = ($value*1.8) +32;
$unit1 = "degree";
$unit1 .= $plural;
$unit1 .= " celsius (C)";
$unit2 = "degrees fahrenheit (F)";
} else if ($convert == "farcel") {
$result = ($value - 32) * 0.5556;
$unit1 = "degree";
$unit1 .= $plural;
$unit1 .= " fahrenheit (F)";
$unit2 = "degrees celsius (C)";
} else if ($convert == "cmin") {
$result = $value * 0.393701;
$unit1 = "centimeter";
$unit1 .= $plural;
$unit2 = "inches";
} else if ($convert == "incm") {
$result = $value * 2.54;
$unit1 = "inch";
if ($plural == "s") {
$plural = "es";
}
$unit1 .= $plural;
$unit2 = "centimeters";
} else if ($convert == "mefe") {
$result = $value * 3.28084;
$unit1 = "meter";
$unit1 .= $plural;
$unit2 = "feet";
} else if ($convert == "feme") {
$result = $value * 0.3048;
if ($plural != "s") {
$unit1 = "foot";
} else {
$unit1 = "feet";
}
$unit2 = "meters";
} else if ($convert == "kmmi") {
$result = $value * 0.621371;
$unit1 = "kilometer";
$unit1 .= $plural;
$unit1 .= " (km)";
$unit2 = "miles (mi)";
} else if ($convert == "mikm") {
$result = $value * 1.60934;
$unit1 = "mile";
$unit1 .= $plural;
$unit1 .= " (mi)";
$unit2 = "kilometers (km)";
} else if ($convert == "kglb") {
$result = $value * 2.20462;
$unit1 = "kilogram";
$unit1 .= $plural;
$unit1 .= " (kg)";
$unit2 = "pounds (lb)";
} else if ($convert == "lbkg") {
$result = $value * 0.453592;
$unit1 = "pound";
$unit1 .= $plural;
$unit1 .= " (lb)";
$unit2 = "kilograms (kg)";
} else if ($convert == "mloz") {
$result = $value * 0.0338146;
$resultUK = $value * 0.035195083;
$unit1 = "milliliter";
$unit1 .= $plural;
$unit1 .= " (ml)";
$unit2 = "U.S. ounces (oz), or ";
$unit2 .= number_format($resultUK, "3", ".", ",");
$unit2 .= " ounces in British measurement. (1 US oz is 1.0408 UK oz)";
} else if ($convert == "ozml") {
$result = $value * 29.57303;
$resultUK = $value * 28.41306;
$unit1 = "ounce";
$unit1 .= $plural;
$unit1 .= " (oz)";
$unit2 = "milliliters, but only if you're using US ounces. If you're using British ounces, the answer is ";
$unit2 .= number_format($resultUK, "2", ".", ",");
$unit2 .= " milliliters (because one US oz is 1.0408 UK oz)";
}
echo "Conversion Tool";
echo "Result of your conversion:";
echo "$value $unit1 is equal to ";
// format the result (number value, decimal places, decimal separator, thousands separator)
echo number_format($result, "2", ".", ",");
echo " $unit2. ";
echo " ";
echo "You can do another conversion if you'd like: ";
echo "$form_block";
}
?> |
$form_block = "
";
// remove commas and spaces
trim($value1);
$valuetemp = preg_replace("/,/", "", $value1);
$value = preg_replace("/ /", "", $valuetemp);
// get the first character in the value to later check that it's not a letter
$check = substr($value, 0, 1);
// in case no number is entered, the page refreshes
if ($value == "") {
echo "Table de Conversion";
echo "Plusieurs conversions sont possibles,telles que longueurs,volumes,poids,degrés... ";
echo "Inscrire un nombre dans la boite, choisir la conversion et appuyez sur Go ";
echo "Utilisez le point à la place de la virgule dans les décimales. ";
echo " ";
echo "$form_block";
} else if (($check != "0") && ($check != "1") && ($check != "2") && ($check != "3") && ($check != "4") && ($check != "5") && ($check != "6") && ($check != "7") && ($check != "8") && ($check != "9") && ($check != ".") && ($check != "-")) {
// oddly the quotes were needed above around 0 etc for absolute values otherwise letters parsed through
echo "Table de Conversion";
echo "Plusieurs conversions sont possibles, telles que longueurs,volumes,poids,degrés... ";
echo "Inscrire un nombre dans la boite, choisir le mode de conversion et appuyez sur le bouton";
echo "Utilisez le point à la place de la virgule dans les décimales. ";
echo " ";
echo "$form_block";
} else {
{
if ($value == 1) {
$plural = "";
} else
$plural = "s";
}
if ($convert == "celfar") {
$result = ($value*1.8) +32;
$unit1 = "degree";
$unit1 .= $plural;
$unit1 .= " celsius (C)";
$unit2 = "degrees fahrenheit (F)";
} else if ($convert == "farcel") {
$result = ($value - 32) * 0.5556;
$unit1 = "degree";
$unit1 .= $plural;
$unit1 .= " fahrenheit (F)";
$unit2 = "degrees celsius (C)";
} else if ($convert == "cmin") {
$result = $value * 0.393701;
$unit1 = "centimeter";
$unit1 .= $plural;
$unit2 = "inches";
} else if ($convert == "incm") {
$result = $value * 2.54;
$unit1 = "inch";
if ($plural == "s") {
$plural = "es";
}
$unit1 .= $plural;
$unit2 = "centimeters";
} else if ($convert == "mefe") {
$result = $value * 3.28084;
$unit1 = "meter";
$unit1 .= $plural;
$unit2 = "feet";
} else if ($convert == "feme") {
$result = $value * 0.3048;
if ($plural != "s") {
$unit1 = "foot";
} else {
$unit1 = "feet";
}
$unit2 = "meters";
} else if ($convert == "kmmi") {
$result = $value * 0.621371;
$unit1 = "kilometer";
$unit1 .= $plural;
$unit1 .= " (km)";
$unit2 = "miles (mi)";
} else if ($convert == "mikm") {
$result = $value * 1.60934;
$unit1 = "mile";
$unit1 .= $plural;
$unit1 .= " (mi)";
$unit2 = "kilometers (km)";
} else if ($convert == "kglb") {
$result = $value * 2.20462;
$unit1 = "kilogram";
$unit1 .= $plural;
$unit1 .= " (kg)";
$unit2 = "pounds (lb)";
} else if ($convert == "lbkg") {
$result = $value * 0.453592;
$unit1 = "pound";
$unit1 .= $plural;
$unit1 .= " (lb)";
$unit2 = "kilograms (kg)";
} else if ($convert == "mloz") {
$result = $value * 0.0338146;
$resultUK = $value * 0.035195083;
$unit1 = "milliliter";
$unit1 .= $plural;
$unit1 .= " (ml)";
$unit2 = "U.S. ounces (oz), or ";
$unit2 .= number_format($resultUK, "3", ".", ",");
$unit2 .= " ounces (Mesure Anglaise). (1 US oz is 1.0408 UK oz)";
} else if ($convert == "ozml") {
$result = $value * 29.57303;
$resultUK = $value * 28.41306;
$unit1 = "ounce";
$unit1 .= $plural;
$unit1 .= " (oz)";
$unit2 = "milliliters, mais seulement si vous employez les US ounces. Si vous employez les British ounces, la réponse est ";
$unit2 .= number_format($resultUK, "2", ".", ",");
$unit2 .= " milliliters (Parceque un US oz correspond à 1.0408 UK oz)";
}
echo "Table de Conversion";
echo "Résultat de votre conversion:";
echo "$value $unit1 est égal à ";
// format the result (number value, decimal places, decimal separator, thousands separator)
echo number_format($result, "2", ".", ",");
echo " $unit2. ";
echo " ";
echo "Vous pouvez faire d'autres conversion si vous le voulez: ";
echo "$form_block";
}
?>
|