• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 173
  • Last Modified:

Is $x revisable by 6?

Hello,

I would like to check if $x is revisable by 6.

if (revisable_by_6($x)) {}

For example these numbers should pass:
   6, 12, 36, 54, 600

I use PHP 5.

Thanks!
0
hankknight
Asked:
hankknight
3 Solutions
 
MikkkCommented:
if ((x mod 6)==0) {}
0
 
glcumminsCommented:
Do you mean 'divisible'?

function is_divisible($number, $divisor)
{
   if ($number % $divisor == 0)
     return true;
   else
     return false;
}

Call using

  $response = is_divisible(54, 6);
0
 
glcumminsCommented:
Note to Mikkk: 'mod' is not a PHP term. The modulus operator is '%'.
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
MacAnthonyCommented:
In php, it would be:

if (( $x % 6 ) == 0 ) {}

Syntax was wrong, but the principle was right.
http://us2.php.net/manual/en/language.operators.arithmetic.php
0
 
MikkkCommented:
sorry, I would put % but my fingers wote mod.... :)
0
 
hankknightAuthor Commented:
Thanks.  And yes, I made a typo... "revisable" should be "divisible"
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now