Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help writing a php code that can read a text file and sort an array that displays the min, max, average, and standard deviation

Need help writing a php code that can read a text file and sort an array that displays the min, max, average, and standard deviation and shows up on an html.

The array that needs to be in a txt file

1,2,3,4,5,6,7,8,9 345,23,346,234,234,456,756,345,123 456,0,234,234,45,678,789,70,436,342,234,345,35 5,5,5,5,5,5,5

It should look like this

Row Min Max Avg Stdev
1 1 9 5 2.5819888974716
2 23 756 318 197.84730363479
3 0 789 299.84615384615 235.31381539548
4 5 5 5 0

and here is my code

echo "";

echo "

:;

echo "html>";

$testArray=fopen(" ../data_files/lab05.txt","r")

//return ($arr, &$min, &$max, &$avg, &$std_dev);

}

$i=0;

while(($line=fgets($testArray))!=FALSE){

$array = explode ("," $line);

$i++;

echo "

";

echo "

";

echo "

";

echo "

";

echo "

";

echo "

";

echo "

";

function computeStats($arr,&$min, &$max, &$avg, &$std_dev)

{

$min = min ($arr);

$max = max ($arr);

$avg = array_sum($arr) / count($arr);

$variance= 0.0;

foreach($array as $arr){

$variance+= pow(($arr - $avg),2);

}

$std_dev=(float)sqrt($variance/count($array));

{

}

echo "

RowMinAvgstd_dev
Test Min Max Avg Stddev
";

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David Kroenke

11th Edition

0132302675, 9780132302678

More Books

Students also viewed these Databases questions

Question

How do gifts fit into estate planning?

Answered: 1 week ago

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago