hello, Im stuck on a problem with my code. the program takes a csv file and breaks it down to use. I am using an array and displaying the dates and the differences between each open/close and hi/lo. My code does that much now after thats complete i want to display the highest and lowest of both the hi/lo and open/close. open/close is assigned to $dif_o hi/lo assigned to $dif. Ive tried the min max function but that’s not working. not sure how to go about doing this heres my code:
[php]
<?php
//read the data from the file and display player's name and team
$fp = fopen("http://cs.uww.edu/data/stocks/AAPL.csv", 'r');
if(!$fp){
echo "could not open the file!";
exit();
}
displayData($fp);
function displayData($fp){
//define an array to store data
$stocks = array();
//read each line into an array, save name and team using an associative array
while(!feof($fp)){
// read the current line
$info = fgetcsv($fp, 250, ',');
// add data only if data is nonempty
if ($info[0] !=""){
// read the name into a variable
$date = $info[0];
// add this information to associative array
//use $date as the key
$dif =($info[2]-$info[3]);
$dif_o=$info[1]-$info[4];
$stocks[$date]= $dif;
$stocks[$date]=$dif_o;
}// end if
echo "Date: ".$date.", Difference between Hi and Lo: ".$dif.", Difference between Open and Close: ".$dif_o."
";
}//end while
//sort data
echo max($dif);
// display name and team
// echo "Date: ".$date.", Difference between Hi and Lo: ".$dif.", Difference between Open and Close: ".$dif_o."
";
}
?>
[/php]