What does the expression $i%3 == 0 mean?

    2 answers 2

    This conditional expression returns true or false. Returns true if the remainder of dividing $i by 3 is 0 Otherwise returns false

    $i is a variable, variables $i , $j very often used in cycles as counters, that is, they change in each iteration of the loop

    % is an arithmetic operator called "Modulo Division", it returns the integer remainder of division

    Arithmetic operators in php

    == is a comparison operator in php, returns true if both variables are equal after type conversion, otherwise returns false

    Php comparison operators

    • and why $ before i ? - 4per
    • one
      @ 4per "Names of all variables in PHP must begin with the $ sign - it is much easier for the interpreter to" understand "and distinguish them, for example, in strings." General notions about variables in PHP - Stanislav Grot

    This expression returns true if the remainder of dividing $i by 3 is 0, and false if it is not 0.