Porl123 Posted July 26, 2008 Share Posted July 26, 2008 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 Quote Link to comment Share on other sites More sharing options...
rawb Posted July 26, 2008 Share Posted July 26, 2008 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; Quote Link to comment Share on other sites More sharing options...
Porl123 Posted July 26, 2008 Author Share Posted July 26, 2008 That's working but for some reason anything below 256 sets off the error message too :[ Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted July 26, 2008 Share Posted July 26, 2008 Why not just check to see if there is a period (.) in the variable? $dec = 46.4; if(strstr($dec,".")){ die("You have a decimal!"); } That there will die with the error message. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.