PHP Classes

File: doc.txt

Recommend this page to a friend!
  Classes of Jonas Raoni Soares Silva   Advanced Randomizer   doc.txt   Download  
File: doc.txt
Role: Documentation
Content type: text/plain
Description: Fast step-by-step help
Class: Advanced Randomizer
Retrieve random items based on given probability
Author: By
Last change:
Date: 19 years ago
Size: 805 bytes


Class file image Download
This class is very simple to be used. Follow step-by-step instructions: 1. Include the main class source file: include( 'lib.probabilityRandom.php' ); 2. Instanciate the class $prExample = new probabilityRandom; 3. Add items to the class using the "add( data, probability )" method. The first parameter can be any data defined by you, the second parameter defines the probability of this "data" appear in the results. $prExample->add( "I have more chances than everybody :]", 20 ); $prExample->add( "I have good chances", 10 ); $prExample->add( "I'm difficult to appear...", 1 ); 4. At this point, everything is ready. Just call the "get" method. It will choose one between the previously added items relying on the probability level and will return the "data" assigned to it.