...

View Full Version : Complex Arrays



danielwarner
03-02-2008, 06:16 PM
Previously i asked in this forum about finding information from torrent announcers and thanks to Inigoesdr :thumbsup: i found a useful resource. The problem i now face is how to extract the information from the arrays the code produces.

Heres an example of the code that the script produces using var_dump:

array(1) {
[0]=>
array(3) {
["announce"]=>
string(45) "[[[HTTP://ANNOUNCER URL.com]]]"
["creation date"]=>
int([[[UNIX TIMESTAMP]]])
["info"]=>
array(4) {
["files"]=>
array(14) {
[0]=>
array(2) {
["length"]=>
int([[[FILE no.1 LENGTH]]])
["path"]=>
array(1) {
[0]=>
string(52) "[[[FILE NAME]]]"
}
}
[1]=>
array(2) {
["length"]=>
int([[[FILE no.2 LENGTH]]])
["path"]=>
array(1) {
[0]=>
string(52) "[[[FILE NAME]]]"
}
}
[2]=>
array(2) {
["length"]=>
int([[[FILE no.3 LENGTH]]])
["path"]=>
array(1) {
[0]=>
string(52) "[[[FILE NAME]]]"
}
}
}
}
}
}

My problem is that if i were to want to access the file name of the second file in the array then i assume id want to use code similar to
$name[1] = $torrent["info"]["files"][0]["path"][0]; although this doesn't work (most probably because its horribly wrong :/)

Can anyone correct me here where i'm wrong.

Thanks.

digitalfiz
03-02-2008, 09:41 PM
Try:


$name[1] = $torrent[0]['info']['files'][1]['path'][0];

danielwarner
03-03-2008, 01:59 AM
Marvelous!

Like most errors, it can be fixed with just a little attention to what your coding!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum