comprobarvertical

    0

    1

    izian db

    The while loop is checking to see if the current value of $vermell and $groc match the values in the $_SESSION["tauler"] array. If they do, that means the $i variable is equal to the value in the count($_SESSION["tauler"]) - 1 spot in the array, which means that the loop has run four times and the condition has been met. If the condition isn't met, the code inside the while loop keeps running until it is met. Inside the while loop, the code checks to see if the value in the $i variable is equal to the value in the count($_SESSION["tauler"]) - 1 spot in the array. If it is, that means the loop has run through all of the items in the array, which means the condition has been met. If the condition isn't met, the code inside the while loop keeps running until it is met.

    Shortcut: comprobarvertical

    $i = 0;
    $vermell = 0;
    $groc = 0;
    while ($vermell < 4 && $groc < 4 && $i <= count($_SESSION["tauler"]) - 1) {
      if ($_SESSION["tauler"][$i][$columna] == 1) {
        $vermell++;
        $groc = 0;
      } elseif ($_SESSION["tauler"][$i][$columna] == 2) {
        $groc++;
        $vermell = 0;
      }
      $i++;
    }
    if ($vermell == 4 || $groc == 4) {
      return true;
    } else {
      return false;
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.