From 8c0d70b97089d78017dfc5780e948a66b5cf844a Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Tue, 12 Feb 2019 12:35:07 -0500 Subject: [PATCH] Remove each() calls Replacing them with foreach. This is faster and each is being deprecated. --- models/front/members/list.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/models/front/members/list.php b/models/front/members/list.php index b83b901f..57f01ac7 100755 --- a/models/front/members/list.php +++ b/models/front/members/list.php @@ -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) { -- 2.17.1