Jump to content

Random number


Cruisecar

Recommended Posts

Hmmm...then why the title? :-P

Also...you are being just a tad vague. What conditions need to be met in order for it to return true/false? What will determine the precentage? Are you just entering whole numbers which will represent a %? Or are these numbers an actual percentage of something? You would need to know that, in order for us to help point ya in the right direction. Just a small example but...you can do something like:

[code]<?php

  $ognumber = $_POST['number'];
  //Or Whatever Method You're Using To Get This Value

  $percent = ($ognumber / 100);

  if($percent  > .49)

  {echo"At Least 50%";}

  else

  {echo"Less Than Half, Mate.";}

?>[/code]
Link to comment
https://forums.phpfreaks.com/topic/9156-random-number/#findComment-33741
Share on other sites

hi, i noticed caeser hasnt replied, so ill try n help
[code]
function chance($input) {
  $rand= rand(0, 100) //get a number, 0 - 100
  if($rand > $input) {
/*if the number is more than random then its outside the percentage. e.g. $rang = 80  and $input = 60 then the rand is part of the 40%.*/
    return 1; //outside the chance%
  } else {
    return 0; //inside the chance%
  }
}
[/code]

im not 100% sure how you return values in PHP, ive kinda forgotten :P. but that should work good :)
Link to comment
https://forums.phpfreaks.com/topic/9156-random-number/#findComment-33754
Share on other sites

[!--quoteo(post=371725:date=May 5 2006, 11:18 PM:name=Cruisecar)--][div class=\'quotetop\']QUOTE(Cruisecar @ May 5 2006, 11:18 PM) [snapback]371725[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Your a genious, I knew all of the stuff you said - I just didn't piece it together. Thankyou!
[/quote]

happy to help :D if you can find the solved button, using it is much appreciated here!
Link to comment
https://forums.phpfreaks.com/topic/9156-random-number/#findComment-33756
Share on other sites

[!--quoteo(post=371726:date=May 5 2006, 11:19 PM:name=Mattyspatty)--][div class=\'quotetop\']QUOTE(Mattyspatty @ May 5 2006, 11:19 PM) [snapback]371726[/snapback][/div][div class=\'quotemain\'][!--quotec--]
happy to help :D if you can find the solved button, using it is much appreciated here!
[/quote]

Erm, where is it?
Link to comment
https://forums.phpfreaks.com/topic/9156-random-number/#findComment-33758
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.