Jump to content

php question help


puretony

Recommended Posts

The below information will be saved into a text file named Inwine.txt.

Design a php script to read it and output its contents to a file name Output.txt which includes the following:

 

*the average wine list

*the cheapest and most expensive wine

 

Wine Producer                           Wine name             Wine price

Angove’s LTD                             Sherry                 $5.75

Gravida                                         Claret                       $9.50

Mildara Wines Pty Ltd                 White Port           $8.69

Angove’s LTD                             Claret                   $11.30

Penfolds Wine Ltd                   Riesling               $10.45

Best’s Wine Pty Ltd                   White Burgundy $12.90

Lake’s Folly                                 Chardonnay         $15.70

Chateau Yeildara                   Rose                         $8.50

Coolabah                               Lumbrussco       $4.90

Barossa Valley                             Cuvee                 $6.75

 

please help me

Link to comment
https://forums.phpfreaks.com/topic/176340-php-question-help/
Share on other sites

You can use file to retrieve the contents of Inwine.txt.  You can loop through each row with foreach, and use explode to separate the values.  You can use sort or rsort to sort the array.  max and min to find out highest and lowest prices.  You can use array_sum and count to find out average price. You can use file_put_contents to put the info in Output.txt

 

Good luck!

Link to comment
https://forums.phpfreaks.com/topic/176340-php-question-help/#findComment-929440
Share on other sites

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.