title: check if value is the same in while loop
body: <p>I'm converting a csv file to xml using the following function:</p>
  
  <p>I want to repeat the same action if $records[$row] value is the same as the previous time that it looped through.  How can I accomplish this?</p>
  
  <pre><code>while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
    $num = count($data);
    $records[] = $data;
  
    $stringData .= '&lt;PayTo PTPayeeID="' . $records[$row][2];
  
    // if the value of $records[$row][2] is the same I want to repeat an action.
    echo "&lt;div id=\"row\"&gt;&lt;div id=\"num\"&gt;" .$row. "&lt;/div&gt;";
    $row++;
  
    for ($c=0; $c &lt; $num; $c++) {
       if ($c != 1) {
         echo "&lt;div class=\"field\"&gt;" . $data[$c] . "&lt;/div&gt;";
       }
    }
  }
  </code></pre>