Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 12-20-2011, 10:10 PM making odds
Novice Talker

Posts: 12
Trades: 0
Im looking to for a way to make something show up on a %, i need this to work with (if).

example, when the page is loaded text will say Good Day 95% of the time, and 4% says Hello, and 1% says You Win.


Sorry if I'm not making any sense, I'm finding this hard to put in to words.
xwhitchx is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-20-2011, 10:19 PM Re: making odds
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
PHP Code:
$roll rand(1100);

if(
$roll <= 95)
     echo 
'Good Day';
elseif(
$roll == 100)
     echo 
'You Win';
else
     echo 
'Hello'
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is offline
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 12-20-2011, 11:27 PM Re: making odds
Novice Talker

Posts: 12
Trades: 0
Thank you this will help a lot
xwhitchx is offline
Reply With Quote
View Public Profile
 
Old 12-22-2011, 08:29 PM Re: making odds
Physicsguy's Avatar
404 - Title not found

Posts: 920
Name: Scott Kaye
Location: Ontario
Trades: 0
If you find your NullPointer's script to be generating the same numbers over and over each time you refresh the page, you'll need to use this function to fix it.
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!
Physicsguy is offline
Reply With Quote
View Public Profile
 
Old 12-22-2011, 09:16 PM Re: making odds
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Quote:
Originally Posted by Physicsguy View Post
If you find your NullPointer's script to be generating the same numbers over and over each time you refresh the page, you'll need to use this function to fix it.
Only if you're using a very old version of PHP.
Quote:
Note: As of PHP 4.2.0, there is no need to seed the random number generator with srand() or mt_srand() as this is now done automatically.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is offline
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 12-22-2011, 10:18 PM Re: making odds
Physicsguy's Avatar
404 - Title not found

Posts: 920
Name: Scott Kaye
Location: Ontario
Trades: 0
Oh cool, I can't believe I didnt know that!
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!
Physicsguy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to making odds
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.23358 seconds with 12 queries