this is untested but should get you going down the right road

and this is assuming that you add the value = (6*X + 1*Y)

you didn't say that, so I am just guessing.

<?php

$var   = 4;
$x     = 1;
$y     = 2;
$value = 0;

if ( ($var % 2) == 0 ) {
  $value = ($var * $x);
} else {
  $value = ( ( ($var-1) * $x ) + $y );
}

echo $value;
?>

Give this a shot, it should give you the results that you are looking for.
But remember, this is untested, and just a guess as to the results you are
looking for.

Jim Lucas

----- Original Message -----
From: "Frank Keessen" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, June 10, 2003 2:22 PM
Subject: [PHP] Math with php


> Hi,
>
> Hope you can help me:
>
> How can i do the following in PHP:
>
> When a variable is for example:
>
> $a = 7
>
> I must do the following 6 * X and 1 * Y, but when $a = 4 it must only do 4
* X.
>
> So every when the value is odd i must do # * X and # * Y..
>
> Some examples or hints are very welcome! Sory that this is maybe a little
bit vague... Questions? e-mail!
>
> Regards,
>
> Frank
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to