Explain, please, in words what this record means.

direction == 1 && (offset=0) 

Is it possible to rewrite it in a more familiar form, for example, through a conditional structure?

    1 answer 1

    Check the value of direction and if it is equal to 1 , then set the offset to 0 ;

    whole expression

    • returns 0 if direction is 1
    • returns false if direction is not equal to 1

    about rewrite, depending on how it is used. This is possible, but there will be an extra assignment and the offset must be declared in advance.

     ((offset=direction==1?0:offset) && false) 

    so

     if (direction==1) offset=0; 

    but then the result of the verification direction will not return.

    • one
      About the result is not true. If direction is 1, then the result is 0 , if not 1, then the result is false . Exactly, 0 and false. - dzhioev
    • Apparently the console output failed me, well, then just if it would be even more correct hardly anyone seriously separates 0 and false - zb '
    • @eicto, in spite of which functions :) out of the box PHP function strpos ...> Returns the position in which the search line is located relative to the beginning of the haystack line (regardless of the offset.) Also note that the position of the line is measured from 0 and not from 1. - thunder
    • @thunder I had in this particular example, of course, can be divided, but then it is easier to do 0/1 - zb '
    • @eicto, just write that> hardly anyone seriously separates 0 and false is bad! They need to be divided, because if we learn to not divide them, then there will be kindergarten questions "and why ..." :) I mean that this line is setting a bad example :) - thunder