@@ -116,8 +116,7 @@ class Template {
116116 }
117117 $ this ->file [$ varname ] = $ this ->filename ($ filename );
118118 } else {
119- reset ($ varname );
120- while (list ($ v , $ f ) = each ($ varname )) {
119+ foreach ($ varname as $ v =>$ f ) {
121120 if ($ f == "" ) {
122121 $ this ->halt ("set_file: For varname $ v filename is empty. " );
123122 return false ;
@@ -170,8 +169,7 @@ class Template {
170169 $ this ->varvals [$ varname ] = $ value ;
171170 }
172171 } else {
173- reset ($ varname );
174- while (list ($ k , $ v ) = each ($ varname )) {
172+ foreach ($ varname as $ k =>$ v ) {
175173 if (!empty ($ k )) {
176174 if ($ this ->debug ) print "array: set * $ k* to * $ v*<br> \n" ;
177175 $ v = preg_replace (array ('/\$([0-9])/ ' , '/ \\\\([0-9])/ ' ), array ('$\1 ' , '\\1 ' ), $ v );
@@ -226,8 +224,7 @@ class Template {
226224 $ this ->set_var ($ target , $ str );
227225 }
228226 } else {
229- reset ($ varname );
230- while (list ($ i , $ v ) = each ($ varname )) {
227+ foreach ($ varname as $ i =>$ v ) {
231228 $ str = $ this ->subst ($ v );
232229 $ this ->set_var ($ target , $ str );
233230 }
@@ -249,8 +246,7 @@ class Template {
249246 * return all variables as an array (mostly for debugging)
250247 */
251248 function get_vars () {
252- reset ($ this ->varkeys );
253- while (list ($ k , $ v ) = each ($ this ->varkeys )) {
249+ foreach ( $ this ->varkeys as $ k => $ v ) {
254250 $ result [$ k ] = $ this ->get_var ($ k );
255251 }
256252 return $ result ;
@@ -273,8 +269,7 @@ class Template {
273269 }
274270 return $ str ;
275271 } else {
276- reset ($ varname );
277- while (list ($ k , $ v ) = each ($ varname )) {
272+ foreach ($ varname as $ k => $ v ) {
278273 if (isset ($ this ->varvals [$ v ])) {
279274 $ str = $ this ->varvals [$ v ];
280275 } else {
@@ -303,8 +298,7 @@ class Template {
303298 return false ;
304299 }
305300
306- reset ($ m );
307- while (list ($ k , $ v ) = each ($ m )) {
301+ foreach ($ m as $ k => $ v ) {
308302 if (!isset ($ this ->varkeys [$ v ])) {
309303 $ result [$ v ] = $ v ;
310304 }
0 commit comments