Jump to content

Table to Array


Recommended Posts

Hey guys i need help with a CURL code. I need to retreive all the data in a table located at http://www.listenlive.nl/tvgenre.php?g=1&page=0 and parse the data to finish with an array that looks like this:

$row[0][station_name] = '3BTV';
$row[0][stream_link] = '420';
$row[0][stream_type] = 'wma';
$row[0][country] = 'United Kingdom';
$row[0][genre][0] = 'Variety';
$row[0][genre][1] = 'Alternative';
$row[0][genre][2] = 'Culture';
$row[0][rating] = '1/5';

I need that for each rows of the table where the first array number would increment $row[1], $row[2] ...
My PHP code is incomplete. I currently have a loop for all the TR's of the page ... and when i loop all the TD's inside the TR's it returns a load of crap ... I am unsure where to go from here. Any help would be apreciated thx

This is my code:

$ch = curl_init();
$categ[url] = 'http://www.listenlive.nl/tvgenre.php?g=1&page=0';
curl_setopt($ch, CURLOPT_URL, $categ[url]);
curl_setopt($ch, CURLOPT_POST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookies);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies);
curl_setopt($ch, CURLOPT_COOKIE, $cookies);
curl_setopt($ch, CURLOPT_REFERER, $categ[url]);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, $nav);
$data2 = curl_exec($ch);
$dom2 = new DOMDocument();
$trs = $dom2->getElementsByTagName('tr');
foreach ($trs as $tr) {
echo "<pre>";
echo "</pre>";
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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