title: How to parse json array using php foreach?
body: <p>I want to get id,url,img and title of videos in the JSON data.My current code doesn't output anything
  could any one tell me what i am doing wrong.Thanks</p>
  
  <pre><code>$code2 = stripslashes($_POST['outputtext']);
  $data = json_decode($code2, true);
  $i = 0;
  
  foreach($data-&gt;videos as $values)
  {
      echo $values-&gt;id . "\n";
      echo $values-&gt;url . "\n";
      echo $values-&gt;img . "\n";
      echo $values-&gt;title . "\n";
  $i++;
  }
  </code></pre>
  
  <p>data:</p>
  
  <pre><code>{
      "cat": {
          "id": "1234567",
          "source_id": null,
          "title_en": "first season",
          "description_en": "This is spring category ",
      },
      "videos": [{
          "id": "312412343",
          "url": "\/2015-07-17\/1abcd.mp4",
          "img": "image\/44\/\/2015-07-17\/1abcd.jpg",
          "title": "first",
  
      }, {
          "id": "2342343",
          "url": "\/2015-07-16\/2dcdeg.mp4",
          "img": "images\/44\/\/2015-07-16\/2dcdeg.jpg",
          "title": "second",
  
  
      }];
  
  
  }
  </code></pre>
  
  <p>validated json data:</p>
  
  <pre><code>{
     "cat":{
        "id":"1234567",
        "source_id":null,
        "title_en":"first season",
        "description_en":"This is spring category "
     },
     "videos":[
        {
           "id":"312412343",
           "url":"\/2015-07-17\/1abcd.mp4",
           "img":"image\/44\/\/2015-07-17\/1abcd.jpg",
           "title":"first"
        },
        {
           "id":"2342343",
           "url":"\/2015-07-16\/2dcdeg.mp4",
           "img":"images\/44\/\/2015-07-16\/2dcdeg.jpg",
           "title":"second"
        }
     ]
  }
  </code></pre>