0) { $currWeight = 0; $rnd = rand() % $totalWeight; foreach ($metas as $meta) { $currWeight += $meta['weight']; if ($currWeight > $rnd) { return $meta; } } } return null; } protected static function getMetaList() { if (!self::$metaList) { self::$metaList = getMetaTable('Dailyselection@Dailyselection.php'); } return self::$metaList; } protected static function mustBeSlotGroupHash() { if (!self::$slotGroupHash) { self::$slotGroupHash = array(); foreach (self::getMetaList() as $meta) { $slots = explode("|", $meta['slot']); foreach ($slots as $slot) { if (!getXVal(self::$slotGroupHash, $slot)) { self::$slotGroupHash[$slot] = array(); } array_push(self::$slotGroupHash[$slot], $meta); } } } } protected static $slotGroupHash; protected static $metaList; }