Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Complex Arrays

  1. #1
    Regular Coder
    Join Date
    Oct 2005
    Location
    Surrey, England
    Posts
    286
    Thanks
    2
    Thanked 2 Times in 2 Posts

    Complex Arrays

    Previously i asked in this forum about finding information from torrent announcers and thanks to Inigoesdr 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:
    PHP Code:
    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
    PHP Code:
    $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.
    Daniel Warner
    - - - - - - - - - -
    GuitarMart.co.uk - Free Online Classified Advertisement for Guitarists in the United Kingdom. Free Ads with a Free Photo.

  • #2
    New Coder
    Join Date
    Mar 2008
    Location
    Lakeland, FL
    Posts
    39
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Try:
    PHP Code:
    $name[1] = $torrent[0]['info']['files'][1]['path'][0]; 

  • #3
    Regular Coder
    Join Date
    Oct 2005
    Location
    Surrey, England
    Posts
    286
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Marvelous!

    Like most errors, it can be fixed with just a little attention to what your coding!
    Daniel Warner
    - - - - - - - - - -
    GuitarMart.co.uk - Free Online Classified Advertisement for Guitarists in the United Kingdom. Free Ads with a Free Photo.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •