Jump to content

Recommended Posts

I've been making this roulette page in php for the last day or so and everything's fine except this one error message that isn't showing up.

I have the outcome to the wheel, betting on red/black, odd/even all put into the arrays $bet[] and $won[] and I've used array_sum to get them afterwards. I've tried to make sure they're using whole numbers by putting in

if(!round(array_sum($bet))) {

echo "Invalid bet";

}

 

I was hoping that would just work on its own, but you can still place bets containing decimal places if there's at least one box filled with a whole number. Anyone have any ideas? I'd be really grateful :] thanks

Link to comment
https://forums.phpfreaks.com/topic/116717-rounding-with-error-message/
Share on other sites

To check if a value is a round number with no decimal places, ctype_digit() should work (http://www.php.net/manual/en/function.ctype-digit.php).

 

Also you can/probably should cast the type to an integer value before doing anything with it just to be sure.

 

$var = (int)$var;

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.