I want to check if a number is divisible by 6 and if not I need to increase it until it becomes divisible.
how can I do that ?
$num += (6-$num%6)%6;
no need for a while loop! Modulo (%) returns the remainder of a division. IE 20%6 = 2. 6-2 = 4. 20+4 = 24. 24 is divisible by 6.