Jump to content

us66mo

New Members
  • Posts

    3
  • Joined

  • Last visited

us66mo's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Excellent, thank you! Interesting that foreach (array_keys($tokenArr) as $val) I used elsewhere for similar code to be replaced did not work, but your code did.
  2. Thanks for the response! Here is the code for the while loop. "each" is combined with $errMess==" " : while (($errMess == "") && (list(,$val) = each($tokenArr))) { $this->log->notice(sprintf($SearchEngineConst['TokenInSequenceMsg'],$val["item"])); if ($val["type"] == "operand") { $this->log->notice(sprintf($SearchEngineConst['OperandPushedToArrayMsg'],$val["item"])); $tableName = getOrigTmpName(); if ($val["UnaryOp"] == "") { if (preg_match("/^\{(.*)\}$/",$val["item"],$arr)) { $val["item"] = $arr[1]; $this->getSelection($val["item"],$path,"folder",$tableName,$errMess); } else { $this->getSelection($val["item"],$path,"word",$tableName,$errMess); } } else { if (preg_match("/^\{(.*)\}$/",$val["item"],$arr)) { $val["item"] = $arr[1]; $this->getNotSelection($val["item"],$path,"folder",$tableName,$errMess); } else { $this->getNotSelection($val["item"],$path,"word",$tableName,$errMess); } } if ($errMess == "") { $val["item"] = $tableName; array_push($operandStack,$val); } } else if ($val["type"] == "operator") { $op1 = array_pop($operandStack); $op2 = array_pop($operandStack); if (($op1 == NULL) || ($op2 == NULL)) { $errMess = $errMessPrefix.$SearchEngineConst['EmptyOperandStackErrMsg']; $this->log->error($errMess); } if ($errMess == "") { $this->log->notice(sprintf($SearchEngineConst['ExecuteOperationMsg'],$val[item])); $this->log->notice(sprintf($SearchEngineConst['OperationInfoMsg'],$op1,$val[item],$op2)); $this->executeOperation($op1,$op2,$val["item"],$resOperand,$errMess); // old: $this->executeOperation($op1,$op2,$val["item"],&$resOperand,$errMess); } if ($errMess == "") { $this->log->notice(sprintf($SearchEngineConst['OperationResultMsg'],$resOperand[item])); array_push($operandStack,$resOperand); } } else { $errMess = $errMessPrefix.sprintf($SearchEngineConst['TokenTypeUnknownErrMsg'],$val[type]); $this->log->error($errMess); } } //END WHILE LOOP
  3. I am updating my website to PHP 8.2 and I am replacing, among other things, all each() functions. Most are quite easy to replace, but this code has me stumped. How do I replace each() here with a foreach() function. I tried double nesting 2 foreach() functions, but it didn't work. while (($errMess == "") && (list(,$val) = each($tokenArr))) { ... execution commands ... Any help would be greatly appreciated! Thanks!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.