Jump to content

not working array file


slaper

Recommended Posts

I have a text file  zongebruikers.txt with some http : like this

http://slaper.be/Gegevens_Installatie.txt

http://slaper.be/Fjord/Gegevens_Installatie.txt

http://zon.cindyenguy.be/opbrengsten/Gegevens_Installatie.txt

http://eerdekens.com/zon/Gegevens_Installatie.txt

 

i want to open the ****.txt , but the script read only the last one. Can sombody help why?

 

<?php
$file = fopen ("zongebruikers.txt", "r")or die ("ERROR READ"); 
while (!feof($file)) { 
$link[]=fgets($file, 1024); 
} 
fclose ($file);


echo '<pre>'.print_r($link, true).'</pre>';

foreach ($link as $lijn_nr => $http) {

echo "nr".$lijn_nr."=".$http;
$lines=array();//echo '<pre>'.print_r($lines, true).'</pre>';echo "<br>";
$lines=file($http);
echo '<pre>'.print_r($lines, true).'</pre>';echo "<br>";
$split=explode(":",$lines[1]);
	$wattpiek=trim($split[1]);
	echo $wattpiek;echo "<br>";
}

?> 

Link to comment
https://forums.phpfreaks.com/topic/163429-not-working-array-file/
Share on other sites

hmm, why dont you do something more like this:

<?php

$urls = file('zongebruikers.txt');

foreach ($urls as $url)
{
$lines = file($url);

foreach ($lines as $line)
{
	$split = explode(":", $line);
	$wattpiek = trim($split[1]);
	echo $wattpiek;
	echo "<br />";
}
}

?>

 

Also notice that you have a hardcoded array index:

$split=explode(":",$lines[1]);

 

i have the same problem, the script read only de last one in the text file and put this in a array, but he do not show the other once.

 

thats what I see:

http://slaper.be/Gegevens_Installatie.txt not show

http://slaper.be/Fjord/Gegevens_Installatie.txt not show

http://zon.cindyenguy.be/opbrengsten/Gegevens_Installatie.txt not show

http://eerdekens.com/zon/Gegevens_Installatie.txt here he read the last one

PV Installatie Familie Eerdekens 

3960

26 juli 2008

www.dgs-solar.be

DGS Solar

24 x Yingli YL165

Sunnyboy SB3800

-4 graden Zuid, 40 graden Dakhelling

Solarlog 100e

3360 Bierbeek

 

www.sonnenertrag.eu/nl/familie-eerdekens/bierbeek/3362/3324.html

 

 

 

1.395

0

09-04-01

0

 

Try this and see what output you get:

 

<?php

$urls = file('zongebruikers.txt');

foreach ($urls as $url)
{
echo 'URL: ', $url, '<br />';

$lines = file($url);

foreach ($lines as $line)
{
	echo '    LINE: ', $line, '<br />';

	list($a, $b) = explode(":", $line);
	echo trim($b). '<br />';
}
}

?>

Thats the output. he gives only the last ***.txt

 

URL: http://slaper.be/Gegevens_Installatie.txt

URL: http://slaper.be/Fjord/Gegevens_Installatie.txt

URL: http://zon.cindyenguy.be/opbrengsten/Gegevens_Installatie.txt

URL: http://eerdekens.com/zon/Gegevens_Installatie.txt

    LINE: 0 Naam: PV Installatie Familie Eerdekens

PV Installatie Familie Eerdekens

    LINE: 1 Kwpiek: 3960

3960

    LINE: 2 Start installatie: 26 juli 2008

26 juli 2008

    LINE: 3 Website Installateur: www.dgs-solar.be

www.dgs-solar.be

    LINE: 4 Naam Installateur: DGS Solar

DGS Solar

    LINE: 5 Soort pannel aantal: 24 x Yingli YL165

24 x Yingli YL165

    LINE: 6 Omvormer: Sunnyboy SB3800

Sunnyboy SB3800

    LINE: 7 Orientatie:-4 graden Zuid, 40 graden Dakhelling

-4 graden Zuid, 40 graden Dakhelling

    LINE: 8 Data captatie:Solarlog 100e

Solarlog 100e

    LINE: 9 Plaats:3360 Bierbeek

3360 Bierbeek

    LINE: 10 Gastenboek:

 

    LINE: 11 link naar sonnenertrag:www.sonnenertrag.eu/nl/familie-eerdekens/bierbeek/3362/3324.html

www.sonnenertrag.eu/nl/familie-eerdekens/bierbeek/3362/3324.html

    LINE: 12 link jou grafiek op sonnenertrag:

 

    LINE: 13 jouw email:

 

    LINE: 14 jouw bannerjpg202x135:

 

    LINE: 15 schaal vandaag kwpiek gedeeld door: 1.395

1.395

    LINE: 16 Installatie_zonphp leegt database: 0

0

    LINE: 17 Installatie_zonphp importeren vanaf "jj-mm-dd": 08-08-01

08-08-01

    LINE: 18 Afwijking servertijd SEC: 0

0

 

Thats the output

 

 

URL: http://www.slaper.be/Gegevens_Installatie.txt

 

Warning: file(http://www.slaper.be/Gegevens_Installatie.txt ) [function.file]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in C:\Webserver\Apache2.2\htdocs\SlaperFjord\txt.php on line 12

 

Warning: Invalid argument supplied for foreach() in C:\Webserver\Apache2.2\htdocs\SlaperFjord\txt.php on line 14

URL: http://www.slaper.be/Fjord/Gegevens_Installatie.txt

 

Warning: file(http://www.slaper.be/Fjord/Gegevens_Installatie.txt ) [function.file]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in C:\Webserver\Apache2.2\htdocs\SlaperFjord\txt.php on line 12

 

Warning: Invalid argument supplied for foreach() in C:\Webserver\Apache2.2\htdocs\SlaperFjord\txt.php on line 14

URL: http://www.zon.cindyenguy.be/opbrengsten/Gegevens_Installatie.txt

 

Warning: file(http://www.zon.cindyenguy.be/opbrengsten/Gegevens_Installatie.txt ) [function.file]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in C:\Webserver\Apache2.2\htdocs\SlaperFjord\txt.php on line 12

 

Warning: Invalid argument supplied for foreach() in C:\Webserver\Apache2.2\htdocs\SlaperFjord\txt.php on line 14

URL: http://www.eerdekens.com/zon/Gegevens_Installatie.txt

    LINE: 0 Naam: PV Installatie Familie Eerdekens

PV Installatie Familie Eerdekens

    LINE: 1 Kwpiek: 3960

3960

    LINE: 2 Start installatie: 26 juli 2008

26 juli 2008

    LINE: 3 Website Installateur: www.dgs-solar.be

www.dgs-solar.be

    LINE: 4 Naam Installateur: DGS Solar

DGS Solar

    LINE: 5 Soort pannel aantal: 24 x Yingli YL165

24 x Yingli YL165

    LINE: 6 Omvormer: Sunnyboy SB3800

Sunnyboy SB3800

    LINE: 7 Orientatie:-4 graden Zuid, 40 graden Dakhelling

-4 graden Zuid, 40 graden Dakhelling

    LINE: 8 Data captatie:Solarlog 100e

Solarlog 100e

    LINE: 9 Plaats:3360 Bierbeek

3360 Bierbeek

    LINE: 10 Gastenboek:

 

    LINE: 11 link naar sonnenertrag:www.sonnenertrag.eu/nl/familie-eerdekens/bierbeek/3362/3324.html

www.sonnenertrag.eu/nl/familie-eerdekens/bierbeek/3362/3324.html

    LINE: 12 link jou grafiek op sonnenertrag:

 

    LINE: 13 jouw email:

 

    LINE: 14 jouw bannerjpg202x135:

 

    LINE: 15 schaal vandaag kwpiek gedeeld door: 1.395

1.395

    LINE: 16 Installatie_zonphp leegt database: 0

0

    LINE: 17 Installatie_zonphp importeren vanaf "jj-mm-dd": 08-08-01

08-08-01

    LINE: 18 Afwijking servertijd SEC: 0

0

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.