[thelist] PHP and My coding ignorance

David Bindel dbindel at austin.rr.com
Thu Aug 7 16:46:44 CDT 2003


AJ wrote:
> Okay a user submits a number. If that number is 7 or greater
> I have to call function y. However if that number is a
> multiple of 7 (say 21) the its got to call function x. But
> the best bit is if the number is say greater that a multiple
> (Say 25) I will have to call function x and function z and
> add their results together. I have tried the above code but
> maybe I am just dim and don't know maths all that well :) Any
> help welcomed. I've posted some code I was messing around
> with to see if I could get it to work. But no it did not :(

How's this?

<?php
$divisor = 7;
if ($number >= $divisor)
	y();
if ($number % $divisor)
	$somevar = x() + z();
else
	x();
?>

I wasn't too sure about this that you wrote:

> if the number is say greater that a multiple (Say 25)

Isn't (any number modulo x) != 0 greater than a multiple of x?
(Mathematically speaking, there exists an infinite number of numbers
greater than "a multiple of x")

HTH,
David

--
    David I. Bindel
  Website Development
 dbindel at austin.rr.com
  www.davidbindel.com



More information about the thelist mailing list