puretony Posted October 3, 2009 Share Posted October 3, 2009 <?php $file = fopen("Inwine.txt", "r") or exit("Unable to open file!"); while(!feof($file)) { echo fgets($file). "<br />"; } fclose($file); $wine; $wine["Angove's LTD__Producer- Sherrey"] = "5.75"; $wine["Gravida__Wine Name- Claret"]= "9.50"; $wine["Mildara Wines PTY LTD__Wine Name- White Port"] = "8.69"; $wine["Angove's LTD__Wine Name- Claret"] = "11.30"; $wine["Penfolds Wine PTY__Wine Name- Riesling"] = "10.45"; $wine["Best's Wine PTY LTD__Wine Name- White Burgundy"] = "12.90"; $wine["Lake's Folly__Wine Name- Chardonnay"] = "15.70"; $wine["Chateau Yeildara__Wine Name- Rose"] = "8.50"; $wine["Coolabah__Wine Name- Lumbrussco"] = "4.90"; $wine["Barossa Valley__Wine Name- Cuvee"] = "6.75"; sort($wine); echo "----------------------------------------------<br/>"; echo "<br/>"; echo "Cheapest : \$" . $wine[0] ; echo "<br/>\n"; echo "Most expensive : \$" . $wine[count($wine)-1]; echo "<br/>"; echo "<br/>"; echo "----------------------------------------------<br/>"; $average = array_sum($wine) / count($wine); echo "<br/>"; echo "Average wine price is $$average<br/>"; echo "<br/>"; echo "----------------------------------------------<br/>"; echo "<br/>"; echo "Created Outwine.txt file!"; ?> i would like to create an output file named Outwine.txt and want to write all information inside outwine Quote Link to comment Share on other sites More sharing options...
RussellReal Posted October 3, 2009 Share Posted October 3, 2009 <?php ob_start(); $file = fopen("Inwine.txt", "r") or exit("Unable to open file!"); while(!feof($file)) { echo fgets($file). "<br />"; } fclose($file); $wine; $wine["Angove's LTD__Producer- Sherrey"] = "5.75"; $wine["Gravida__Wine Name- Claret"]= "9.50"; $wine["Mildara Wines PTY LTD__Wine Name- White Port"] = "8.69"; $wine["Angove's LTD__Wine Name- Claret"] = "11.30"; $wine["Penfolds Wine PTY__Wine Name- Riesling"] = "10.45"; $wine["Best's Wine PTY LTD__Wine Name- White Burgundy"] = "12.90"; $wine["Lake's Folly__Wine Name- Chardonnay"] = "15.70"; $wine["Chateau Yeildara__Wine Name- Rose"] = "8.50"; $wine["Coolabah__Wine Name- Lumbrussco"] = "4.90"; $wine["Barossa Valley__Wine Name- Cuvee"] = "6.75"; sort($wine); echo "----------------------------------------------<br/>"; echo "<br/>"; echo "Cheapest : \$" . $wine[0] ; echo "<br/>\n"; echo "Most expensive : \$" . $wine[count($wine)-1]; echo "<br/>"; echo "<br/>"; echo "----------------------------------------------<br/>"; $average = array_sum($wine) / count($wine); echo "<br/>"; echo "Average wine price is $$average<br/>"; echo "<br/>"; echo "----------------------------------------------<br/>"; echo "<br/>"; $out = fopen("Outwine.txt",'w'); fwrite($out,ob_get_flush()); fclose($out); echo "Created Outwine.txt file!"; ?> 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.