Well, how would you do it in real life? You check for a remainder, right? If the remainder is 0, then it is divisible. If the remainder is anything else, it is not divisible. From what you know, you can do this:
function isDivisibleBy2($number) {
$quotient = $number / 2;
return ($quotient == floor($quotient));
}
This function divides by 2 and gets the result. If there is a remainder, then the quotient will have a decimal place. So ($quotient == floor($quotient)) will be false. But if the quotient is an integer, then the number is divisible by 2 and ($quotient == floor($quotient)) will return true.
But you can save all this hassle because PHP has a remained operator, %. So just use:
if ($number % 2 == 0)
Diego