Multi-Dimensional Arrays Help - And Other Questions on Arrays

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #91
    line 41: replace $row with $row['Cells']

    Comment

    • Ciary
      Recognized Expert New Member
      • Apr 2009
      • 247

      #92
      yep, just noticed i forgot it there :)

      Comment

      • fjm
        Contributor
        • May 2007
        • 348

        #93
        Your good Mr. Dormilich! :) You too Ciary.. This is exactly what I mean when I say that you have to really understand HOW arrays work before you can even troubleshoot them. I think that has always been my frustration. I looked at the code over half a dozen times and didn't see that. Now, it is so plain..

        Comment

        • fjm
          Contributor
          • May 2007
          • 348

          #94
          can i ask one more question pleeeeeese?? before I let you guys go to sleep? :)

          Why is it foreach( $row['Cells'] as $cell ) and not foreach( $rows as $cell )

          Why isn't it the same?

          Comment

          • Ciary
            Recognized Expert New Member
            • Apr 2009
            • 247

            #95
            i must say, it was because i missed an "array(" so gigantic arrays can even trouble the best coders (i'm not one of them). biggest problem with someone elses code is you might see problems differently. thats why its very difficult to find your own errors.

            Comment

            • Dormilich
              Recognized Expert Expert
              • Aug 2008
              • 8694

              #96
              with such large structures, it's easy to loose oversight…

              Comment

              • Ciary
                Recognized Expert New Member
                • Apr 2009
                • 247

                #97
                because there is an array after 'rows' before 'cells'. i didnt notice it at first

                edit: and its way to early for us to go to sleep but thanks for the concern :)

                Comment

                • fjm
                  Contributor
                  • May 2007
                  • 348

                  #98
                  I know what you mean Ciary.. I have a hard time finding my own errors some times too. In fact... some of the absolute hardest errors for me have been array errors. I can usually find out whats going on but when I cannot get the correct result set, I wind up like a dog chasing his tail. That's why I am here today. I figured that I had better get down to business and start asking some serious questions. It's kinda like a doctor that can successfully preform an operation on your brain but doesn't know how to remove a wart. :)

                  Comment

                  • fjm
                    Contributor
                    • May 2007
                    • 348

                    #99
                    Originally posted by Ciary
                    because there is an array after 'rows' before 'cells'. i didnt notice it at first

                    edit: and its way to early for us to go to sleep but thanks for the concern :)
                    Thanks.. As for me.. its 6:30 am and I haven't been to sleep yet. Now you can see why my wife hates me. :) I spend all night coding. Since I have started programming, coffee and sleepless nights have become my best friend.

                    Comment

                    • Ciary
                      Recognized Expert New Member
                      • Apr 2009
                      • 247

                      sleeples nights and 12 cups of coffee each hour. sounds like paradise :)

                      EDIT WOOHOO 100 posts

                      Comment

                      • fjm
                        Contributor
                        • May 2007
                        • 348

                        lol... Wow.. I never posted so many times in a forum in my life. I think my record was 30 something and that was also on this forum. This one is the record though.

                        Ok, I am going to try and sleep for a little while. A sincere thanks to both of you guys! I am also putting the both of you on my forum buddy list. :)

                        Comment

                        • Ciary
                          Recognized Expert New Member
                          • Apr 2009
                          • 247

                          ok cya later fjm and good night/morning :)

                          Comment

                          • Dormilich
                            Recognized Expert Expert
                            • Aug 2008
                            • 8694

                            rest well not dreaming of arrays… they have the possibility to haunt programmer's dreams :)

                            Comment

                            • fjm
                              Contributor
                              • May 2007
                              • 348

                              Thanks a buch guys! I will give my brain a few hours off and then start all over again. :)

                              Talk to you guys soon.

                              Frank

                              Comment

                              • fjm
                                Contributor
                                • May 2007
                                • 348

                                Daddy, look! NO HANDS! :P~

                                Code:
                                $colors = array
                                (
                                  array
                                  (
                                    'black' => 'sky',
                                    'blue' => 'ocean',
                                    'pink' => 'san francisco'
                                  )
                                );
                                
                                echo $colors['0']['blue'];
                                For any other poor soul having a hard time with arrays, look at it like this..

                                Code:
                                            $colors['0']['blue'];
                                foreach--------^ key-^----^ value
                                Yields Ocean. ;)

                                Now kiddies.. when all I need is a single value, instead of using a foreach loop and typing 3 extra lines, I can just type one by using this. ;)

                                I still may not understand Atli's monster 7D array but I am sure well on my way. Now when I get an undefined index notice, it actually MEANS something to me.

                                As elementary as arrays may seem to most, I honestly struggled with them but I really feel like I have a much better handle on what is happening and what to do to troubleshoot one and so, I have achieved my goal here thanks to Dormilich, Ciary and Markus.

                                Comment

                                Working...