Jump to content

Search the Community

Showing results for tags 'min'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

Found 1 result

  1. i have a problem with a script, the script read a file (csv) and stores the last value of each line in an array, then i calculate the maximun,minimun and average of the values in the array, but with big files the script give me an incorrect value for the maximun,minimun and average, with the file 8.csv the calculations are correct but with the file 1.csv the values are wrong, the only difference i see is that the file 1.csv is much larger than the other. Thanks for your help!!! This is the code: <?php $variable2=file("1.csv"); $i=0; foreach($variable2 as $var){ if($i==0){ $i++; }else{ $datos=explode(",",$var); $valor=$datos[count($datos)-1]; if($valor!= -3000){ $todos[$i-1]=$valor; $i++; } } } $promedio=array_sum($todos) / count($todos); $maximo=max($todos); $minimo=min($todos); echo "MAXIMO = ".$maximo." MINIMO = ".$minimo." PROMEDIO = ".$promedio; ?> And this is a part of the file 1.csv (the full file have more than 60.000 lines) OBJECTID,pointid,grid_code,potrero_ID,MOD13Q1.A2 7300.0,7300.0,1.0,1,6431 7498.0,7498.0,1.0,1,6684 7499.0,7499.0,1.0,1,6431 7500.0,7500.0,1.0,1,6431 7501.0,7501.0,1.0,1,6431 7502.0,7502.0,1.0,1,6431 7503.0,7503.0,1.0,1,6431 7504.0,7504.0,1.0,1,6304 7697.0,7697.0,1.0,1,6734 7698.0,7698.0,1.0,1,6734 7699.0,7699.0,1.0,1,6127 7700.0,7700.0,1.0,1,6127 Expected values: Maximun: 9307 Minimun: -650 Average: 6555,211347 Output values: Maximun: 999 Minimun: -104 Average: 6555,3296310272 If you want you can download the code and input files here: https://www.dropbox.com/s/y4vpjm6086rj3s3/script.zip Thanks.
  • 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.