[advanced search]
Results from the most recent live auction are here.
22 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Domain Name Industry Newsletter
Go Back   NamePros.Com > Design and Development > Programming
User Name
Password

Old 06-01-2006, 02:11 PM   · #1
PoorDoggie
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
 
Name: Tom
Location: UK
Trader Rating: (36)
Join Date: Jan 2005
Posts: 2,390
NP$: 300.50 (Donate)
PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice
2 piece randomisation script.

Hi,

I need to write a script that will show a string 50% of the time and another string the other 50% of the time, but not always one after the other.

ie: I don't want someone to be able to anticipate which one is coming next.

so, can anyone help me randomise two strings, lets call them str1 and str2? I just don't know very much about randomisation. (well, nothing in fact)

They can't be bias though, the probability of either showing up should be 50%.

Thanks
Tom


Please register or log-in into NamePros to hide ads
PoorDoggie is offline   Reply With Quote
Old 06-01-2006, 02:23 PM   · #2
MrBarby
NamePros Member
 
Trader Rating: (2)
Join Date: May 2006
Posts: 74
NP$: 0.00 (Donate)
MrBarby is on a distinguished road
PHP Code:
if(rand(0,1) == 0)
    echo
$str1;
else
    echo
$str2;


Should work for just 2 strings
MrBarby is offline   Reply With Quote
Old 06-01-2006, 02:26 PM   · #3
PoorDoggie
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
 
Name: Tom
Location: UK
Trader Rating: (36)
Join Date: Jan 2005
Posts: 2,390
NP$: 300.50 (Donate)
PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice
that simple huh?

Thanks a lot!
PoorDoggie is offline   Reply With Quote
Old 06-01-2006, 03:40 PM   · #4
SecondVersion
while ($awake){ code(); }
 
SecondVersion's Avatar
 


Name: Eric
Location: Kentucky
Trader Rating: (142)
Join Date: Mar 2005
Posts: 4,268
NP$: 1152.00 (Donate)
SecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond reputeSecondVersion has a reputation beyond repute
Member of the Month
MOTM September 2005 Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Cancer Alzheimer's Protect Our Planet
PHP Code:
echo (mt_rand(0, 1) == 0) ? $str1 : $str2;


Cleaner Sorry, had to
__________________

SecondVersion.com - The Personal Blog of SecondVersion
Domain Name Portfolio - Get your free copy. - Version 1.0.3 now available!!
SecondVersion is offline   Reply With Quote
Old 06-01-2006, 04:04 PM   · #5
PoorDoggie
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
 
Name: Tom
Location: UK
Trader Rating: (36)
Join Date: Jan 2005
Posts: 2,390
NP$: 300.50 (Donate)
PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice
what is the difference between mt_rand and rand?
PoorDoggie is offline   Reply With Quote
Old 06-01-2006, 06:25 PM   · #6
Dan
Buy my domains.
 
Dan's Avatar
 
Name: Dan
Trader Rating: (63)
Join Date: Feb 2006
Posts: 2,801
NP$: 54.00 (Donate)
Dan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant future
Autism Autism Autism Autism Autism Autism Autism
It is 4 times faster.
Dan is offline   Reply With Quote
Old 06-02-2006, 12:40 AM   · #7
Peter
NamePros Staff
 
Peter's Avatar
 
Name: Peter
Location: Scotland
Trader Rating: (47)
Join Date: Nov 2003
Posts: 4,337
NP$: 2039.40 (Donate)
Peter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud ofPeter has much to be proud of
Child Abuse Save The Children Save The Children
Originally Posted by SecondVersion
PHP Code:
echo (mt_rand(0, 1) == 0) ? $str1 : $str2;


Cleaner Sorry, had to



it maybe cleaner but harder to read.
Peter is offline   Reply With Quote
Old 06-02-2006, 07:53 AM   · #8
PoorDoggie
Soon to be RICHdoggie!
 
PoorDoggie's Avatar
 
Name: Tom
Location: UK
Trader Rating: (36)
Join Date: Jan 2005
Posts: 2,390
NP$: 300.50 (Donate)
PoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nicePoorDoggie is just really nice
not really, but the point is that I define a variable before and then if rand(1,0)==0 then I change it, so I can't do it the second way!

Thanks
Tom
PoorDoggie is offline   Reply With Quote
Closed Thread

NamePros is a revenue sharing forum.

Thread Tools

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Site Sponsors
RealTechNetwork EscrowDNS EscrowDNS
Advertise your business at NamePros
All times are GMT -7. The time now is 09:40 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0