title: Parsing PHP Multidimensional Array
body: <p>Here (given below) is some very simple php parsing multidimensional array stuff I am doing. I am just searching for 'highlighting' key and then storing some key value pairs in another array. Is there any better way to achieve this (I mean with respect to performance), rather than have n foreach loops to get to what you want.</p>
  
  <pre><code>$json_O=json_decode(file_get_contents($url),true);
       foreach($json_O as $section1=&gt;$items1){
          if($section1==highlighting){
              foreach($items1 as $section2=&gt;$items2){
                      $key=$section2;
                      foreach($items2 as $section3=&gt;$items3){
                          foreach ($items3 as $section4=&gt;$items4){
                              $value=$items4;
                              $found[]=array('Key' =&gt; $key, 'Value' =&gt; $value);
  </code></pre>
  
  <p>Here is a sample php object I am trying to parse:</p>
  
  <pre><code>Array
  (
      [responseHeader] =&gt; Array
          (
              [status] =&gt; 0
              [QTime] =&gt; 3
              [params] =&gt; Array
                  (
                      [indent] =&gt; on
                      [start] =&gt; 0
                      [q] =&gt; russian
                      [fragsize] =&gt; 40
                      [hl.fl] =&gt; Data
                      [wt] =&gt; json
                      [hl] =&gt; on
                      [rows] =&gt; 8
                  )
  
          )
  
      [response] =&gt; Array
          (
              [numFound] =&gt; 71199
              [start] =&gt; 0
              [docs] =&gt; Array
  ......
  ......
      [highlighting] =&gt; Array
          (
              [114360] =&gt; Array
                  (
                      [Data] =&gt; Array
                          (
                              [0] =&gt; AMEki has done it better &lt;em&gt;russian&lt;/em&gt;...
  
  ....
  ....
  </code></pre>
  
  <p>Two things now: 1)Can I do it quicker? 2)Can I design it better?</p>