Jump to content

how to create output and write


puretony

Recommended Posts

<?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

Link to comment
https://forums.phpfreaks.com/topic/176356-how-to-create-output-and-write/
Share on other sites

<?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!";
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.