title: limit JSON results using php
body: <p>I am facing with a problem that my json results cannot be limited..
  My json result contains a large number of data, I just want to limit the results so that i can print some of the data in my view page. How can i do that?</p>
  
  <p>Here is my code</p>
  
  <pre><code>$post1 = file_get_contents("........");
      $products = CJSON::decode($post1, true);
      for($i=1;$i&lt;=5;$i++)
              {
                  echo "&lt;pre&gt;";print_r($products);
              }
  </code></pre>
  
  <p>This code prints all the contents. Please help me with this ,waiting for the response.</p>
  
  <p>Output of $products.</p>
  
  <pre><code> Array
      (
          [0] =&gt; Array
              (
                  [id] =&gt; 4380
                  [title] =&gt; 13 Thirteen Patch
                  [barcode] =&gt; PAT-2288
                  [qty] =&gt; 17
                  [url] =&gt; http://www.heygidday.biz/13-thirteen-motorcycle-club-mc-fun-embroidered-quality-new-biker-patch-pat-2288.html
                  [retail_price] =&gt; 4.99
                  [category] =&gt; Array
                      (
                          [id] =&gt; 1
                          [name] =&gt; SMALL PATCHES
                      )
  
                  [bin] =&gt; Array
                      (
                          [id] =&gt; 1
                          [name] =&gt; A1
                      )
  
                  [images] =&gt; Array
                      (
                          [0] =&gt; Array
                              (
                                  [small] =&gt; http://www.heygidday.biz/portal//timthumb.php?src=/files/products/pat-2288-013678719880.jpg&amp;w=30
                                  [middle] =&gt; http://www.heygidday.biz/portal//timthumb.php?src=/files/products/pat-2288-013678719880.jpg&amp;w=100
                                  [source] =&gt; http://www.heygidday.biz/portal/files/products/pat-2288-013678719880.jpg
                              )
  
                      )
  
              )
  ....................
  [6619] =&gt; Array
          (
              [id] =&gt; 12921
              [title] =&gt; Special Police- BLACK Leather Key Fob
              [barcode] =&gt; FOB-0435
              [qty] =&gt; 1
              [url] =&gt; 
              [retail_price] =&gt; 8.99
              [category] =&gt; Array
                  (
                      [id] =&gt; 54
                      [name] =&gt; KEY FOBS
                  )
  
              [bin] =&gt; Array
                  (
                      [id] =&gt; 382
                      [name] =&gt; F10-21
                  )
  
              [images] =&gt; Array
                  (
                  )
  
          )
  
  )
  </code></pre>
  
  <p>Hope this is useful.</p>