title: json_decode assign specific parts to strings
body: <p>I'm using json_decode on $jsontest (for demonstration purposes since it's the exact format). </p>
  
  <p>The problem is I'm trying to assign filename, name, and type for attachment7 to separate variables as a string. I tried   </p>
  
  <pre><code>$attachment7filename = $jsontest2-&gt;{'attachment7-&gt;filename'};       
  </code></pre>
  
  <p>for example and the output is PHP Notice:       </p>
  
  <blockquote>
    <p>Trying to get property of non-object.</p>
  </blockquote>
  
  <p>Any help would be appreciated.     </p>
  
  <pre><code> &lt;?php
  
      $jsontest = '{"attachment7":{"filename":"small.flv","name":"small.flv","type":"video/x-flv"},"attachment2":{"filename":"sample.png","name":"sample.png","type":"image/png"},"attachment6":    {"filename":"small.3gp","name":"small.3gp","type":"video/3gpp"},"attachment5":    {"filename":"small.webm","name":"small.webm","type":"video/webm"},"attachment3":    {"filename":"small.mp4","name":"small.mp4","type":"video/mp4"},"attachment1":        {"filename":"109-1new.jpeg","name":"109-    1new.jpeg","type":"image/jpeg"},"attachment4":    {"filename":"small.ogv","name":"small.ogv","type":"video/ogg"}}';
  
      $jsontest2 = json_decode($jsontest, true);
  
      $attachment7filename = $jsontest2-&gt;{'attachment7-&gt;filename'}; // should be small.flv for example
      $attachment7name = $jsontest2-&gt;{'attachment7-&gt;name'};
      $attachment7type = $jsontest2-&gt;{'attachment7-&gt;type'};
  
      var_dump($attachment7filename);
  
      ?&gt;
  </code></pre>