Call random function on percents?
- by Angelena Godkin
I cannot figure this out.
I need a solution to call a random function for it's percent.
Ex. there is 10% chances that the script calls subscriptions() and 3% chance that the system call the function "specialitems()".
I am stuck in this, so i hope someone can help me with this brainkiller.
<?php
class RandomGifts {
public $chances = '';
public function __construct($user) {
$this->user = $user;
//Find percent for each function
$this->chances = array(
'subscriptions' => 10, // 10%
'specialitems' => 3, // 5%
'normalitems' => 30, // 40%
'fuser' => 50, // 70%
'giftcards' => 7, // 7%
);
//This should call the function which has been calculated.
self::callFunction(?);
}
public function subscriptions(){}
public function specialitems(){}
public function normalitems(){}
public function fuser(){}
public function giftcards(){}
}
?>