Jump to content

GOLF HANDICAP CALCULATOR HELP


wchamber22

Recommended Posts

Once again HELLO FREAKS,

 

I have an equation calculating a users differential for an entered round below:

$differential = ($totalScore - $courseRating) * 113 / $courseSlope

For example, if I shot (wishful thinking) a 74 at a course with a rating of 70.3 and a course slope of 122.

The equation would be (74 - 70.3) * 113 / 122 = 3.42704918.

I want that to be 3.4 WITHOUT ROUNDING and believe I have done that with the following code:

$differential = explode(".", $differential);
$decimal = substr($differential[1],0,1);
$differential = $differential[0].'.'.$decimal;

My question is: How could I use and if else statement to ONLY run the above code if the number is a decimal on the off chance that the equation works out to be a whole number?

FYI, my mysql column differential is a decimal (3,2)

 

Thanks as always!

Link to comment
Share on other sites

Yo Mahngiel,

 

Thanks for the help but I would like to drop all other decimal places WITHOUT rounding.

 

For example, I want 3.4673930 to be 3.4 NOT 3.5 as the round() would do.

 

So do you know how to only execute that code if i have a decimal, if not just skip it because I am assuming it would cause errors if the equation returned a whole number.

 

Thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.