Remove each() calls
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 12 Feb 2019 17:35:07 +0000 (12:35 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 12 Feb 2019 17:35:07 +0000 (12:35 -0500)
Replacing them with foreach. This is faster and each is being
deprecated.

models/front/members/list.php

index b83b901..57f01ac 100755 (executable)
@@ -248,7 +248,7 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo
         // Pre-load settings array with management settings as default using the list above
         $settings = array();
         reset($GLOBALS['showOpts']);
-        while (list($key, $val) = each($GLOBALS['showOpts'])) {
+        foreach ( $GLOBALS['showOpts'] as $key => $val ) {
             $settings[$val] = $this->config['settings'][$val];
         }
 
@@ -435,7 +435,7 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo
                 $regionsRequested = explode( ',', $actionData['request']['region-search'] );
 
                 // Check for numeric ID's only
-                while ( list( $k, $v ) = each( $regionsRequested ) ) {
+                foreach ( $regionsRequested as $k => $v ) {
                     if ( preg_match( '/^[0-9]*$/', trim( $v ) && $v > 0 ) ) {
                         $regions[] = ( $v - 0 );
                     }
@@ -455,7 +455,8 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo
                 $regionsRequested = explode( ',', $actionData['request']['county-search'] );
 
                 // Check for numeric ID's only
-                while ( list( $k, $v ) = each( $regionsRequested ) ) {
+
+                foreach ( $regionsRequested as $k => $v ) {
                     if ( preg_match( '/^[0-9]*$/', trim( $v ) && $v > 0 ) ) {
                         $counties[] = ( $v - 0 );
                     }
@@ -488,7 +489,7 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo
                 $citiesRequested = explode( ',', $actionData['request']['city-search'] );
 
                 // Check for numeric ID's only
-                while ( list( $k, $v ) = each( $citiesRequested ) ) {
+                foreach ( $citiesRequested as $k => $v ) {
                     if ( preg_match( '/^[0-9]*$/', trim( $v ) && $v > 0 ) ) {
                         $cities[] = ( $v - 0 );
                     }
@@ -581,7 +582,7 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo
                 $typesRequested = explode(',', $actionData['request']['type']);
 
                 // Check for numeric IDs only
-                while (list($k, $v) = each($typesRequested)) {
+                foreach ( $typesRequested as $k => $v ) {
 
                     // If it's just numeric - note Explode returns an array element with value = 0 if no string.
                     if (preg_match('/^[0-9]*$/', trim($v)) && $v > 0) {
@@ -612,7 +613,7 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo
                 $catsRequested = explode(',', $actionData['request']['category']);
 
                 // Check for numeric IDs only
-                while (list($k, $v) = each($catsRequested)) {
+                foreach ( $catsRequested as $k => $v ) {
 
                     // If it's just numeric - note Explode returns an array element with value = 0 if no string.
                     if (preg_match('/^[0-9]*$/', trim($v)) && $v > 0) {
@@ -634,7 +635,7 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo
                 $catsRequested = explode('|', $actionData['request']['category-name']);
 
                 // Check for numeric or text selection of categories
-                while (list($k, $v) = each($catsRequested)) {
+                foreach ( $catsRequested as $k => $v ) {
 
                     $vStripped = html_entity_decode(stripslashes(trim($v)));
 
@@ -665,7 +666,7 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo
 
                     // Add ['default'] value to all categories
                     reset($categoryData);
-                    while (list($k, $v) = each($categoryData)) {
+                    foreach ( $categoryData as $k => $v ) {
                         $categoryData[$k]['default'] = false;
                     }
 
@@ -683,7 +684,7 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo
                      */
                     $parentSelected = false;
                     reset($categoryData);
-                    while (list($k, $v) = each($categoryData)) {
+                    foreach ( $categoryData as $k => $v ) {
 
                         // If this is a parent, then clear parent selected
                         if ($v['parent_id'] != $parentSelected) {