Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Is $x revisable by 6?

Posted on 2007-10-18
6
Medium Priority
?
170 Views
Last Modified: 2008-01-09
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
Comment
Question by:hankknight
6 Comments
 
LVL 8

Expert Comment

by:Mikkk
ID: 20101621
if ((x mod 6)==0) {}
0
 
LVL 24

Expert Comment

by:glcummins
ID: 20101644
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
 
LVL 24

Assisted Solution

by:glcummins
glcummins earned 400 total points
ID: 20101657
Note to Mikkk: 'mod' is not a PHP term. The modulus operator is '%'.
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
LVL 11

Accepted Solution

by:
MacAnthony earned 800 total points
ID: 20101677
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
 
LVL 8

Assisted Solution

by:Mikkk
Mikkk earned 800 total points
ID: 20101679
sorry, I would put % but my fingers wote mod.... :)
0
 
LVL 16

Author Comment

by:hankknight
ID: 20101732
Thanks.  And yes, I made a typo... "revisable" should be "divisible"
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses
Course of the Month20 days, 22 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question