+ Post New Thread
Results 1 to 4 of 4
Coding Thread, multi-dimensional arrays in php making my brain hurt in Coding and Web Development; i dont do php often and when i do it's by cobbling together samples from all over using a generic ...
  1. #1
    browolf's Avatar
    Join Date
    Jun 2005
    Location
    Mars
    Posts
    1,540
    Thank Post
    112
    Thanked 89 Times in 75 Posts
    Blog Entries
    47
    Rep Power
    41

    multi-dimensional arrays in php making my brain hurt

    i dont do php often and when i do it's by cobbling together samples from all over using a generic knowledge of scripting and reading the manual. this is beyond cobbling. a 3 dimensional (i think) array with 2 normal ones and an associative one.
    all i want is the name fields outputted to a webpage. simple really but I'm a bit lost here. extreme brain strain

    the print_r gives this

    Code:
    Array
    (
        [words] => Array
            (
                [2009-07-03] => Array
                    (
                        [0] => Array
                            (
                                [query] => "Sarah"
                                [name] => Sarah
                            )
    
                        [1] => Array
                            (
                                [query] => "michael"
                                [name] => michael
                            )
    
                        [2] => Array
                            (
                                [query] => Alaska
                                [name] => Alaska
                            )
    
                    )
    
            )
    
        [as_of] => 1246663258
    )
    help!!

    thx
    Last edited by browolf; 4th July 2009 at 02:06 AM.

  2. #2
    browolf's Avatar
    Join Date
    Jun 2005
    Location
    Mars
    Posts
    1,540
    Thank Post
    112
    Thanked 89 Times in 75 Posts
    Blog Entries
    47
    Rep Power
    41

    Thumbs down

    never mind. just figured it out when i discovered a function called "key" and experimenting in xampp.

  3. #3

    powdarrmonkey's Avatar
    Join Date
    Feb 2008
    Location
    Alcester, Warwickshire
    Posts
    4,867
    Thank Post
    412
    Thanked 778 Times in 651 Posts
    Rep Power
    182
    PHP Code:
    foreach( $origarray['words']['2009-07-03'] as $thing )
    {
        echo 
    "<p>name: {$thing['name']}</p>\n";

    Or perhaps:
    PHP Code:
    foreach( $origarray['words'] as $days )
    {
        foreach( 
    $days as $day )
        {
            foreach( 
    $day as $thing )
            {
                echo 
    "<p>name: {$thing['name']}</p>\n";
            }
        }


  4. #4
    browolf's Avatar
    Join Date
    Jun 2005
    Location
    Mars
    Posts
    1,540
    Thank Post
    112
    Thanked 89 Times in 75 Posts
    Blog Entries
    47
    Rep Power
    41
    thx anyways. I spent about 3 hours earlier figuring it out lol.
    what i've done is

    Code:
    $keydate =  key($decode["words"]);
    $count = count($decode["words"][$keydate]); //counting the number of status
    
    $strdmp="";
    
    for($i=0;$i<$count;$i++){
      //echo $decode["words"][$keydate][$i][name]."<br>";
      $strdmp = $strdmp . $decode["words"][$keydate][$i][name]."<br>";
    }



SHARE:
+ Post New Thread

Similar Threads

  1. [Video] I bet this hurt.....
    By mattx in forum Jokes/Interweb Things
    Replies: 7
    Last Post: 15th June 2009, 07:36 PM
  2. That had to hurt
    By MK-2 in forum General Chat
    Replies: 12
    Last Post: 22nd October 2008, 10:36 AM
  3. [Joke] Brain Teasers
    By Michael in forum Jokes/Interweb Things
    Replies: 10
    Last Post: 9th October 2008, 03:16 PM
  4. [Video] Photosynth: Multi-Dimensional Digital Imaging
    By mattx in forum Jokes/Interweb Things
    Replies: 2
    Last Post: 24th May 2008, 10:49 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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