Re: percentage based output
- From: Matt <matt.foxtrot@xxxxxxxxx>
- Date: Sun, 30 Nov 2008 07:44:16 -0800 (PST)
On Nov 30, 10:33 am, vern <vwenb...@xxxxxxxxx> wrote:
Is there a function in PHP that allows me give the likelihood a
certain piece of text is outputted. Say I want one piece of text to
output to have a 60% chance of occurring and another piece of text to
have 40% of occurring on page load.
Much thanks.
This just sounds like a probability problem.
The usual solution to this problem is to generate a random number
between 0 and 1, and if the number is under (in your case) .6 then
print whatever should print 60% of the time. If it's over .6, print
whatever should print 40% of the time. I don't think there's some
slick method to do all of that for you.
.
- Follow-Ups:
- Re: percentage based output
- From: vern
- Re: percentage based output
- References:
- percentage based output
- From: vern
- percentage based output
- Prev by Date: percentage based output
- Next by Date: Re: percentage based output
- Previous by thread: percentage based output
- Next by thread: Re: percentage based output
- Index(es):