Do you REALLY need all the values in one giant matrix at once?
You might be MUCH better off to read a single line, process it,
discard it, and move on to the next one.
Your webhost is probably wrong and you probably ARE running out of RAM
and/or running afoul of PHP's time_limit in php.ini
set_time_limit(60) inside the loop would fix the time limit thing.
Nothing you can do about the RAM thing, I don't think.
On Tue, August 28, 2007 10:58 pm, Felipe Alcacibar wrote:
> Andres Rojas wrote:
>> Hi all,
>>
>> I'm new in PHP programming and I have a problem with this script. I
>> need
>> to read a large file around 2Mb and several lines (28000). All start
>> Ok,
>> but suddenly the script stop without message error.
>>
>> <?php
>> $fichero="62007lg.txt";
>> $buffer = file($fichero);
>> $lineas = count($buffer);
>>
>> foreach($buffer as $linea){
>>
>> list($day, $month, $year, $hour, $min, $temp, $hum, $dew, $baro,
>> $wind, $gust, $wdir, $rlastm, $rdai, $rmon, $ryear,
>> $heat)=sscanf($linea,"%d %d %d %d %d %f %d %f %f %d %d %d %f %f %f
>> %f %f \n");
>>
>> $mday[]=$day;
>> $mmonth[]=$month;
>> $myear[]=$year;
>> $mhour[]=$hour;
>> $mmin[]=$min;
>> $mtemp[]=$temp;
>> $mhum[]=$hum;
>> $mdew[]=$dew;
>> $mbaro[]=$baro;
>> $mwind[]=$wind;
>> $mgust[]=$gust;
>> $mwdir[]=$wdir;
>> $mrlastm[]=$rlastm;
>> $mdai[]=$rdai;
>> $mrmon[]=$rmon;
>> $mryear[]=$ryear;
>> $mheat[]=$heat;
>> echo"$day $month $year $hour $min $temp $hum $dew $baro $wind $gust
>> $wdir $rlastm $rdai $rmon $ryear $heat <br>";
>> }
>>
>> ?>
>>
>> If only I print the variable $buffer all it's ok, but when I try to
>> fill
>> all the matrix the script doesn't work. If I reduce the number of
>> matrix
>> only a 3 o 4 it's Ok, but If I increase number of this matrix the
>> script
>> crash again.
>>
>> Perhaps it's a problem of memory of server, but my service provider
>> say
>> me that this is not the problem.
>>
>>
>> Thank you very much
>
> Andres:
>
> The info is too poor to see what is wrong, maybe you need to
> review
> a error_reporting() php function, o error_reporting php.ini variable i
> send you some code:
>
> <?php
> error_reporting(E_ALL);
>
> $fichero="62007lg.txt";
> $buffer = file($fichero);
> $lineas = count($buffer);
>
> foreach($buffer as $linea){
>
> $data = preg_split("/\s+/", trim($linea));
> // trim removes all white spaces at the end and the beginning of
> the string.
> $k = 0;
> foreach(array(
> 'mday', 'mmonth',
> 'myear', 'mhour',
> 'mtemp', 'mhum',
> 'mdew', 'mbaro',
> 'mwind', 'mgust',
> 'mwdir', 'mrlastm',
> 'mrdai', 'mrmon',
> 'mryear', 'mheat' ) as $var )
> {
> if(!isset($$var)) $$var = array();
> array_push($$var, $data[$k]);
> echo $var." => ".$data[$k];
> $k++;
> }
>
> }
> ?>
>
> cheers!!
>
> Felipe Alcacibar
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Please vote for this great band:
http://acl.mp3.com/feature/soundandjury/?band=COMPANY-OF-THIEVES
Requires email confirmation.
One vote per day per email limit.
Obvious ballot-stuffing will be revoked.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php