diff --git a/DiffEngine.php b/DiffEngine.php
index 1674882..b58a40f 100644
--- a/DiffEngine.php
+++ b/DiffEngine.php
@@ -312,7 +312,7 @@ class _DiffEngine {
         }
         $matches = $ymatches[$line];
         reset($matches);
-        while (list ($junk, $y) = each($matches)) {
+        foreach ($matches as $junk => $y) {
           if (empty($this->in_seq[$y])) {
             $k = $this->_lcs_pos($y);
             USE_ASSERTS && assert($k > 0);
@@ -320,7 +320,7 @@ class _DiffEngine {
             break;
           }
         }
-        while (list ($junk, $y) = each($matches)) {
+        foreach ($matches as $junk => $y) {
           if ($y > $this->seq[$k-1]) {
             USE_ASSERTS && assert($y < $this->seq[$k]);
             // Optimization: this is a common case:
