title: store the value of toggle button as 1 when it is on else 0 off in same array variable using php
body: <p>I have a toggle button like this inside a table where the button will be created dynamically based on number of rows fetched from the database</p>
  
  <pre><code>&lt;td colspan="3"&gt;&lt;input type="checkbox" class="toggleone" name="attendance[]" id="attendance[]" data-toggle="toggle" data-on="Yes" data-off="No"&gt;&lt;/td&gt;
  </code></pre>
  
  <p>my problem is the values are not correctly posted when clicking on post button 
  But the count of on buttons is correct but not stored correctly in their position</p>
  
  <pre><code>button             obtained output               desired output
  on                    1                             1
  off                   1                             0
  off                   0                             0
  off                   0                             0
  on                    0                             1
  </code></pre>
  
  <p>Someone help me where i am going wrong.
  Here is my for loop</p>
  
  <pre><code>for($i=0;$i&lt;($_SESSION['num1']);$i++)
  {
  
          $subcheck = (isset($_POST['attendance'][$i]))? 1 : 0;
          echo $subcheck;
  }
  </code></pre>