Area Converter - Pixeleco.com"; echo "

Area Converter

Convert

       Back to main page

 

"; if(!($fromvalue)) { echo "Please fill From value"; exit; } if($from==''||$to=='') { echo "Please select both From and To"; exit; } $myFile=fopen('area.dat','r'); do { $line=fgets($myFile,30); $lineArray=explode(' ',$line); if($lineArray[0]==$from) $temp=(double)$lineArray[1]*$fromvalue; } while($lineArray[0]!=$from); fclose($myFile); $myFile=fopen('area.dat','r'); do { $line=fgets($myFile,30); $lineArray=explode(' ',$line); if($lineArray[0]==$to) $tovalue=$temp/(double)$lineArray[1]; } while($lineArray[0]!=$to); fclose($myFile); if($fromvalue>1) $fromadd='s'; if($tovalue>1) $toadd='s'; if($from=='sqinch'&&$fromvalue>1) $fromadd='es'; if($to=='sqinch'&&$tovalue>1) $toadd='es'; if($from=='sqfoot'&&$fromvalue>1) { $from='sqfeet'; $fromadd=''; } if($to=='sqfoot'&&$tovalue>1) { $to='sqfeet'; $toadd=''; } $fromvalue=number_format($fromvalue); $tovalue=number_format($tovalue,3); echo "

Result

"; echo "

"; echo $fromvalue; echo ""." $from".$fromadd." = ".""; echo $tovalue; echo ""." $to

".$toadd; ?>