The |modulo{xx} filter is a mathematical operation filter.
It returns the remainder of dividing the value of the tag by the value of xx.

If the tag’s output is not a numeric type, it will be considered as being 0 (zero) and the filter will simply return 0 (zero).

This filter accepts a second argument which must be numeric (either a whole number or floating point number) and which will be added to the result:[(#VAL{20}|modulo{3, 2.4})] will return "4.4".

to make a display vary in a loop on each loop iteration:[(#COMPTEUR_BOUCLE|modulo{3})] will display "1"for the first record returned by the loop, then "2" for the second record, "0" for the third, then back to "1" for the fourth, "2" for the fifth, etc.

|modulo{x} therefore always returns an integer value between 0 and the value of its first argument less 1.

if 0 (zero) is passed as the argument to the filter ([(#VAL{20}|modulo{0})] for example), a PHP warning will be displayed: —Warning: Division by zero—.

See also the |div, |mult, |moins and |plus filters.

Author Mark Published : Updated : 26/10/12

Translations : català, English, Español, français, Nederlands