Re: percentage based output



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