title: receive serialize data in php sent via ajax and loop through it
body: <p>I am sending a form data via ajax call to a php script. I am serializing the data in ajax and on the php script I want to loop through that data to extract the values. 
  This is my ajax call</p>
  
  <pre><code>$("#submitAttendance").click(function(){
              var data = $('form#attendanceForm').serialize();
              $.ajax({
                  url: 'save-attendance.php',
                  method: 'post',
                  data: {formData: data},
                  success: function(data){
                      console.log(data);
                      alert(data);
                  }
          });
          });
  </code></pre>
  
  <p>and in the <code>attendance.php</code> I am doing</p>
  
  <pre><code>print_r(($_POST['formData']));//prints the entire serialize data
  </code></pre>
  
  <p>when I do this</p>
  
  <pre><code>parse_str($_POST['formData'], $searcharray);
  
  print_r(($searcharray));//prints only last user and all radio buttons
  </code></pre>
  
  <p>I want to extract values so I can save it in db.
  This is my form</p>
  
  <pre><code>&lt;form action="" id="attendanceForm"&gt;
              &lt;?php
              if(mysqli_num_rows($result)&gt;0){
                  while($row = $result-&gt;fetch_assoc()){ ?&gt;
                      &lt;tr&gt;
                          &lt;input type="hidden" value="&lt;?php echo($row['id']);?&gt;"&gt;
                          &lt;td&gt;&lt;input type="text" name="name" value="&lt;?php echo $row['fullname'];?&gt;" readonly&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;input type="text" name="email" value="&lt;?php echo $row['email'];?&gt;" readonly&lt;/td&gt;
                          &lt;td&gt;&lt;input type="text" name="class" value="&lt;?php echo $row['class'];?&gt;" readonly&lt;/td&gt;
                          &lt;td&gt;&lt;input type="radio" value="present" name="&lt;?php echo($row['id']); ?&gt;" checked&gt;&lt;/td&gt;
                          &lt;td&gt;&lt;input type="radio" value="absent" name="&lt;?php echo($row['id']); ?&gt;"&gt;&lt;/td&gt;
                      &lt;/tr&gt;
  
  
                  &lt;?php }
              }
              ?&gt;
                  &lt;input id="submitAttendance" type="button" class="btn btn-success" value="Submit Attendance" name="submitAttendance"&gt;
              &lt;/form&gt;
  </code></pre>