Help with an array - getting all the data without any loss

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lin
Forum Commoner
Posts: 49
Joined: Tue Dec 07, 2010 1:53 pm

Help with an array - getting all the data without any loss

Post by lin »

Hello dear friends, good evening!

while i want to parse this database with 3000 records in it;:

http://www.edi.admin.ch/esv/00475/00698 ... ml?lang=de

with this code:

Code: Select all

<?PHP 

// Original PHP code by Chirp Internet: http://www.chirp.com.au
// Please acknowledge use of this code by including this header.

$url = "http://www.edi.admin.ch/esv/00475/00698/index.html?lang=de";

//$input = @file_get_contents($url) or die("Could not access file: $url");

$input = file_get_contents($url) or die("Could not access file: $url"); 

$regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>";
if(preg_match_all("/$regexp/siU", $input, $matches, PREG_SET_ORDER)) { foreach($matches as $match) {

// $match[2] = all the data i want to collect...
// $match[3] = text that i need to collect - see a detail-page

print_r($matches);

}
}

?>
well see what i get: (i have postet only a part.... the whole stuff is tooo big to post here.... )But wait: what can i do!?
note - i want to get all the data out of this database: http://www.edi.admin.ch/esv/00475/00698 ... ml?lang=de

At the moment we have these results:

how to proceed: ?!
[16] => Array
(


* => <a href="/esv/index/index.html?lang=de" title="Zum Schlagwort-Index" class="webServiceContent" accesskey="6">Index</a>
[1] => "
[2] => /esv/index/index.html?lang=de
[3] => Index
)

[17] => Array
(
* => <a href="/esv/printtool/index.html?lang=de" title="Printtool" class="webServiceContent">Printtool</a>
[1] => "
[2] => /esv/printtool/index.html?lang=de
[3] => Printtool
)

[18] => Array
(
* => <a href="/hinweise/index.html?lang=de" title="Zu den Bedienungshinweisen" class="webServiceContent">Hilfe</a>
[1] => "
[2] => /hinweise/index.html?lang=de
[3] => Hilfe
)

[19] => Array
(
* => <a href="/esv/00475/00698/index.html?lang=de" class="webSpracheAktiv" title="Diese Seite auf deutsch">Deutsch</a>
[1] => "
[2] => /esv/00475/00698/index.html?lang=de
[3] => Deutsch
)

[20] => Array
(
* => <a href="/esv/00475/00698/index.html?lang=fr" class="webSpracheInaktiv" title="Cette page en fran�ais">Fran�ais</a>
[1] => "
[2] => /esv/00475/00698/index.html?lang=fr
[3] => Fran�ais
)
.....and so forth and so forth!! ...
Post Reply