Replaced most each() calls with foreach() in preparation to support php 8

Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
Janos SUTO
2022-01-19 15:40:42 +01:00
parent 7aec4647a5
commit 7a66346036
22 changed files with 47 additions and 45 deletions

View File

@ -27,7 +27,9 @@ class Controller {
public function args($args = array()){
while(list($key, $value) = each($args)) $this->data[$key] = $value;
foreach($args as $key => $value) {
$this->data[$key] = $value;
}
}

View File

@ -53,7 +53,7 @@ class MySQL {
$R = $s->fetchAll(PDO::FETCH_ASSOC);
while(list ($k, $v) = each($R)){
foreach($R as $k => $v) {
$data[$i] = $v;
$i++;
}

View File

@ -47,7 +47,7 @@ class Sphinx {
$R = $s->fetchAll();
while(list ($k, $v) = each($R)){
foreach($R as $k => $v) {
$data[$i] = $v;
$i++;
}
@ -72,7 +72,7 @@ class Sphinx {
$meta->execute();
$R = $meta->fetchAll();
while(list ($k, $v) = each($R)){
foreach($R as $k => $v) {
if($v[0] == "total_found") { $query->total_found = $v[1]; }
}

View File

@ -47,7 +47,7 @@ class SQLite {
$R = $s->fetchAll();
while(list ($k, $v) = each($R)){
foreach($R as $k => $v) {
$data[$i] = $v;
$i++;
}

View File

@ -255,7 +255,8 @@ class Piler_Mime_Decode {
}
while(list($k, $v) = each($result)) {
foreach($result as $k => $v) {
if(strchr($v, "\n")) {
$result[$k] = explode("\n", $v);
}

View File

@ -17,7 +17,7 @@ class Language {
else {
$pref_langs = $this->get_preferred_languages();
while(list($k, $v) = each($pref_langs)) {
foreach($pref_langs as $k => $v) {
if(in_array($v, $langs)) {
$lang = $v;
define('LANG', $lang);
@ -53,7 +53,8 @@ class Language {
$l = explode(";", $_SERVER['HTTP_ACCEPT_LANGUAGE']);
while(list($k, $v) = each($l)) {
foreach($l as $k => $v) {
$a = explode(",", $v);
if(isset($a[0]) && substr($a[0], 0, 2) != 'q=') {

View File

@ -196,7 +196,7 @@ function first_n_characters($what, $n){
$len = 0;
$a = explode(" ", $what);
while(list($k, $v) = each($a)){
foreach($a as $k => $v) {
$x .= "$v "; $len += strlen($v) + 1;
if($len >= $n){ return $x . "..."; }
}
@ -279,7 +279,7 @@ function my_qp_encode($s){
$res = "";
$a = explode("\n", $s);
while(list($k, $v) = each($a)){
foreach($a as $k => $v) {
$part = "";
for($i=0; $i<strlen($v); $i++){
@ -417,7 +417,7 @@ function parse_string_to_array($s = '', $arr = array()) {
parse_str($s, $a);
while(list($k, $v) = each($a)) {
foreach($a as $k => $v) {
if(!isset($arr[$k]) || $arr[$k] == '') $arr[$k] = $v;
}
@ -453,7 +453,7 @@ function convert_date_string_to_ymd_by_template($date_string, $date_template) {
return [$Y, $m, $d];
}
while(list($k, $v) = each($template_array)) {
foreach($template_array as $k => $v) {
$$v = $date_array[$k];
}
@ -613,7 +613,7 @@ function get_ldap_attribute_names($ldap_type = '') {
function htmlentities_on_array($arr = []) {
while(list($k, $v) = each($arr)) {
foreach($arr as $k => $v) {
if(is_array($v)) {
$arr[$k] = htmlentities_on_array($v);
} else {