$res = file(*.txt);if( count( $res )>0 )
{
foreach( $res as $k => $v )
{
eval( "\$i=\$$v" );
if( $i > $maxv );
{
$maxk = $k;
$maxv = $i;
}
}
echo $maxv;
//这里输出$maxv就是最大
//然后处理一下$res[$k]得到=前面的数字}没有经过调试,不过大概思路是这样的.

解决方案 »

  1.   

    <?php
    $filename = "txt.txt";$max = -9999999999;
    $fp = fopen($filename,"r");
    while(list($key,$value) = fgetcsv($fp,1024,"=")) {
      $count[$key]++;
      if($value > $max) {
        $max = $value;
        $max_key = $key;
      }
    }
    echo "[$max_key] $max<pre>";
    print_r($count);
    ?>
    其中文件txt.txt内容:
    a=67
    b=35
    b=98
    c=68
    d=99
      

  2.   

    报错啊Notice: Undefined variable: count in d:\inetpub\wwwroot\maxTest.php on line 7Notice: Undefined index: a in d:\inetpub\wwwroot\maxTest.php on line 7Notice: Undefined index: b in d:\inetpub\wwwroot\maxTest.php on line 7Notice: Undefined index: c in d:\inetpub\wwwroot\maxTest.php on line 7Notice: Undefined index: d in d:\inetpub\wwwroot\maxTest.php on line 7
      

  3.   

    前面加一句
    error_reporting(E_ALL & ~E_NOTICE);
    或先声明所用到的变量