[PRES] [web-pres2] master: Replace a few more each with foreach

[email protected] (Derick Rethans) Fri, 9 Aug 2024 15:16:34 +0000
Newsgroups php.pres
Message-ID <[email protected]>
Author: Derick Rethans (derickr)
Date: 2024-08-09T16:16:15+01:00

Commit: https://github.com/php/web-pres2/commit/9b5e865148e8ea90bd8892b8d2f32c5ee84e1447
Raw diff: https://github.com/php/web-pres2/commit/9b5e865148e8ea90bd8892b8d2f32c5ee84e1447.diff

Replace a few more each with foreach

Changed paths:
  M  display.php


Diff:

diff --git a/display.php b/display.php
index eaa5c4f..9f19c6e 100644
--- a/display.php
+++ b/display.php
@@ -760,7 +760,7 @@ function _table(&$table) {
         } else {
             echo '<table '.$align.' width="'.$width.'" border="'.$table->border.'" '.(isset($table->bgcolor)?"bgcolor=\"{$table->bgcolor}\"":'').'>';
         }
-        while(list($k,$cell)=each($table->cells)) {
+        foreach($table->cells as $k => $cell) {
             if(!($i % $table->columns)) {
                 echo "<tr>\n";
             }
@@ -892,7 +892,7 @@ function _presentation(&$presentation) {
 </head>
 <body>
 HEADER;
-        while(list($this->coid,$obj) = each($this->objs)) {
+        foreach($this->objs as $this->coid => $obj) {
             $obj->display();
         }
         echo <<<FOOTER
@@ -1095,7 +1095,7 @@ function _example(&$example) {
     function _list(&$list) {
         if(isset($list->title)) echo "<h1>".markup_text($list->title)."</h1>\n";
         echo '<ul>';
-        while(list($k,$bul)=each($list->bullets)) $bul->display();
+        foreach($list->bullets as $k => $bul) $bul->display();
         echo '</ul>';
     }
 
@@ -1109,7 +1109,7 @@ function _table(&$table) {
         if(isset($table->title)) echo "<h1 $align>".markup_text($table->title)."</h1>\n";
         echo '<table '.$align.' width="100%" border=1>';
         $i = 0;
-        while(list($k,$cell)=each($table->cells)) {
+        foreach($table->cells as $k => $cell) {
             if(!($i % $table->columns)) {
                 echo "<tr>\n";
             }
@@ -1348,7 +1348,7 @@ function _presentation(&$presentation) {
         pdf_set_info($this->pdf, "Creator", "See Author");
         pdf_set_info($this->pdf, "Subject", isset($presentation->topic)?$presentation->topic:"");
 
-        while(list($this->slideNum,$slide) = each($presentation->slides)) {
+        foreach($presentation->slides as $this->slideNum => $slide) {
             // testing hack
             $slideDir = dirname($this->presentationDir.'/'.$presentation->slides[$this->slideNum]->filename).'/';
             $fn = $this->presentationDir.'/'.$presentation->slides[$this->slideNum]->filename;
@@ -1360,7 +1360,7 @@ function _presentation(&$presentation) {
             $this->objs = $r->getObjects();
             $this->my_new_pdf_page($this->pdf, $this->pdf_x, $this->pdf_y, true);
             $this->pdf_cx = $this->pdf_cy = 0;  // Globals that keep our current x,y position
-            while(list($this->coid,$obj) = each($this->objs)) {
+            foreach($this->objs as $this->coid => $obj) {
                     $obj->display();
             }
             $this->my_new_pdf_end_page($this->pdf);
@@ -1819,7 +1819,7 @@ function _list(&$list) {
                 $list->alpha = $list->start;
             }
         }
-        while(list($k,$bul)=each($list->bullets)) $bul->display();
+        foreach($list->bullets as $k => $bul) $bul->display();
         
     }
 
@@ -1935,7 +1935,7 @@ function _table(&$table) {
         $cell_offset = $max_w/$table->columns;
 
         $i = 1;
-        while(list($k,$cell)=each($table->cells)) {
+        foreach($table->cells as $k => $cell) {
             if(!($i % $table->columns)) {
                 $cell->end_row = false;
             }