CKTIS / PHP
Integer remainder (%)
Find the remainder when dividing an item count by the package size.
Version: PHP 8.4; repository runtime, production runtime not attested
Syntax
$value % $operandFind the remainder when dividing an item count by the package size. Zero means every item fits into a full package.
Operands are converted to integers. A nonzero remainder has the sign of the dividend. A divisor of zero raises DivisionByZeroError.
Evaluation
17 % 5→2(-17) % 5→-212 % 4→0
Examples
<?php
echo json_encode(17 % 5), PHP_EOL;
echo json_encode((-17) % 5), PHP_EOL;
echo json_encode(12 % 4), PHP_EOL;
Result
2 -2 0