title: check the position of values in JSON object array in php
body: <p>I have a <strong>JSON (Line A)</strong> as shown below.</p>
  
  <pre><code>   $fp = fopen('../feeds/ptp-ess_landing.json', 'w');
      fwrite($fp, json_encode($output));
      fclose($fp);
      logActivity();
  
      if(file_exists('../feeds/ptp-ess_landing.json')){
      $data = json_decode(file_get_contents('../feeds/ptp-ess_landing.json'));
      }
  
      {"toggle_multi_tiles":["0","1"]}  // Line A
  </code></pre>
  
  <p>What I want is for the, </p>
  
  <p>=> 1st value in JSON object array above at Line A, <code>animation-delay:0s;</code> is applied. </p>
  
  <p>=> 2nd value, <code>animation-delay:4s;</code> is applied.</p>
  
  <p>This is what I have tried:  </p>
  
  <pre><code>    &lt;?php
      if($data-&gt;toggle_multi_tiles[0]) {                 /* For 1st element */
      ?&gt;
      .multi-tiles a:nth-of-type(1) {
          animation-delay: 0s;
      }
  
      &lt;?php } ?&gt;
  
      &lt;?php
      if($data-&gt;toggle_multi_tiles[1]) {              /* For 2nd element */
      ?&gt;
      .multi-tiles a:nth-of-type(2) {
          animation-delay: 4s;
      }
  
      &lt;?php } ?&gt;
  </code></pre>
  
  <p><strong>Problem Statement:</strong></p>
  
  <p>I have used the if-logic above to <em>apply animation-delay of 0sec</em> onto the 1st value of JSON object array but the if condition will fail there as "0" is false. I am wondering what changes I should make in the php code above so that for</p>
  
  <p>=> 1st value in JSON object array above at Line A, <code>animation-delay:0s;</code> is applied.</p>
  
  <p>=> 2nd value, <code>animation-delay:4s;</code> is applied.</p>