E
E
Extramezz2015-12-13 14:32:10
PHP
Extramezz, 2015-12-13 14:32:10

Analogue of the % operator in PHP?

In JavaScript, the operation 4.2 % 2returns any remainder of the division, which is 0.2 in this example.
In PHP - exclusively integer: 5.5 % 2 //1
How to get a fractional remainder of a division in PHP?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim, 2015-12-13
@Extramezz

fmod

P
Postalus, 2015-12-13
@Postalus

What's the problem with writing your bike?

function modulus($a, $b) {
    return ($a - $b * floor($a / $b));
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question