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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.