L. Smith
L. Smith

Reputation: 105

Check if a number completely divides by 4

I need to know if a changing number divides completely by 4. this is the code that I am currently using:

if ($ResultsCounter %4 != 0){
        $htmlResult .=  "</div><div class='row'>"; 
    }

Problem here is that if the number is greater than 0 it will always divide by 4. I need this to run if the result is a whole number... i.e. 4, 8, 12, 6...

Upvotes: 0

Views: 287

Answers (1)

Hassaan
Hassaan

Reputation: 7672

Change from

if ($ResultsCounter %4 != 0){

to

if ($ResultsCounter %4 == 0){

Upvotes: 3

Related Questions