diff --git a/analytics/classes/calculable.php b/analytics/classes/calculable.php index 63ea392e5c1..af95120f510 100644 --- a/analytics/classes/calculable.php +++ b/analytics/classes/calculable.php @@ -267,7 +267,7 @@ abstract class calculable { foreach ($arrays as $array) { reset($base); - while (list($key, $value) = each($array)) { + foreach ($array as $key => $value) { if (is_array($value) && !empty($base[$key]) && is_array($base[$key])) { $base[$key] = $this->array_merge_recursive_keep_keys($base[$key], $value); } else { diff --git a/lib/moodlelib.php b/lib/moodlelib.php index d701062b899..d75a07252b9 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -2359,8 +2359,10 @@ function get_user_timezone($tz = 99) { $tz = 99; // Loop while $tz is, empty but not zero, or 99, and there is another timezone is the array. - while (((empty($tz) && !is_numeric($tz)) || $tz == 99) && $next = each($timezones)) { - $tz = $next['value']; + foreach ($timezones as $nextvalue) { + if ((empty($tz) && !is_numeric($tz)) || $tz == 99) { + $tz = $nextvalue; + } } return is_numeric($tz) ? (float) $tz : $tz; } diff --git a/lib/webdavlib.php b/lib/webdavlib.php index f71c61ab762..c1307152233 100644 --- a/lib/webdavlib.php +++ b/lib/webdavlib.php @@ -954,7 +954,7 @@ EOD; $result = true; - while (list($localpath, $destpath) = each($filelist)) { + foreach ($filelist as $localpath => $destpath) { $localpath = rtrim($localpath, "/"); $destpath = rtrim($destpath, "/"); @@ -1011,7 +1011,7 @@ EOD; $result = true; - while (list($remotepath, $localpath) = each($filelist)) { + foreach ($filelist as $remotepath => $localpath) { $localpath = rtrim($localpath, "/"); $remotepath = rtrim($remotepath, "/"); diff --git a/message/tests/api_test.php b/message/tests/api_test.php index 35d15f5f661..7139800c460 100644 --- a/message/tests/api_test.php +++ b/message/tests/api_test.php @@ -1398,7 +1398,8 @@ class core_message_api_testcase extends core_message_messagelib_testcase { $this->markTestSkipped("No message processors found"); } - list($name, $processor) = each($processors); + $name = key($processors); + $processor = current($processors); $testprocessor = \core_message\api::get_message_processor($name); $this->assertEquals($processor->name, $testprocessor->name); $this->assertEquals($processor->enabled, $testprocessor->enabled); @@ -1431,7 +1432,8 @@ class core_message_api_testcase extends core_message_messagelib_testcase { if (empty($processors)) { $this->markTestSkipped("No message processors found"); } - list($name, $testprocessor) = each($processors); + $name = key($processors); + $testprocessor = current($processors); // Enable. \core_message\api::update_processor_status($testprocessor, 1); @@ -1457,7 +1459,8 @@ class core_message_api_testcase extends core_message_messagelib_testcase { if (empty($processors)) { $this->markTestSkipped("No message processors found"); } - list($name, $testprocessor) = each($processors); + $name = key($processors); + $testprocessor = current($processors); // Enable. \core_message\api::update_processor_status($testprocessor, 1); diff --git a/mod/quiz/report/statistics/tests/statistics_test.php b/mod/quiz/report/statistics/tests/statistics_test.php index 3f5e0905615..e67653b8cae 100644 --- a/mod/quiz/report/statistics/tests/statistics_test.php +++ b/mod/quiz/report/statistics/tests/statistics_test.php @@ -154,14 +154,15 @@ class quiz_statistics_question_stats_testcase extends basic_testcase { public function get_fields_from_csv($line) { $line = trim($line); $items = preg_split('!,!', $line); - while (list($key) = each($items)) { + $cnt = count($items); + for ($key = 0; $key < $cnt; $key++) { if ($items[$key]!='') { if ($start = ($items[$key]{0}=='"')) { $items[$key] = substr($items[$key], 1); while (!$end = ($items[$key]{strlen($items[$key])-1}=='"')) { $item = $items[$key]; unset($items[$key]); - list($key) = each($items); + $key++; $items[$key] = $item . ',' . $items[$key]; } $items[$key] = substr($items[$key], 0, strlen($items[$key])-1); diff --git a/mod/scorm/aicc.php b/mod/scorm/aicc.php index 14bcb9904a9..8902fd26577 100644 --- a/mod/scorm/aicc.php +++ b/mod/scorm/aicc.php @@ -217,7 +217,7 @@ if (!empty($command)) { $datamodel['[comments]'] = 'cmi.comments'; $datarows = explode("\r\n", $aiccdata); reset($datarows); - while ((list(, $datarow) = each($datarows)) !== false) { + foreach ($datarows as $datarow) { if (($equal = strpos($datarow, '=')) !== false) { $element = strtolower(trim(substr($datarow, 0, $equal))); $value = trim(substr($datarow, $equal + 1)); diff --git a/mod/survey/graph.php b/mod/survey/graph.php index 7422e7d0b3e..75c0c0e381b 100644 --- a/mod/survey/graph.php +++ b/mod/survey/graph.php @@ -88,7 +88,7 @@ $options = explode(",",$question->options); - while (list($key,) = each($options)) { + foreach ($options as $key => $unused) { $buckets1[$key] = 0; $buckets2[$key] = 0; } diff --git a/mod/survey/lib.php b/mod/survey/lib.php index db773b581cf..6d5f7f4e708 100644 --- a/mod/survey/lib.php +++ b/mod/survey/lib.php @@ -539,7 +539,7 @@ function survey_print_multi($question) { echo "