Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!