Skip to content

Instantly share code, notes, and snippets.

@krysits
Created October 18, 2014 19:21
Show Gist options
  • Save krysits/c338749dca13fd7a7177 to your computer and use it in GitHub Desktop.
Save krysits/c338749dca13fd7a7177 to your computer and use it in GitHub Desktop.
<?php
/*
Loto Helper
coded by @krysits
05.05.2014
*/
class Loto extends CI_Controller {
public function index(){
$this->no35();
//$this->bingo();
//$this->viking();
//$this->keno();
}
public function no35(){
$results = $this->_loto(5,35);
$data["res"] = $results;
$this->load->view('simpleloto', $data);
return $results;
}
public function euro(){ // added support for EuroJackpot lottery
$results = $this->_loto(5,50);
$data["res"] = $results;
$results = $this->_loto(2,8);
$data["res2"] = $results;
$this->load->view('simpleloto', $data);
return $results;
}
public function viking(){
$results = $this->_loto(6,48);
$data["res"] = $results;
$this->load->view('simpleloto', $data);
return $results;
}
public function keno(){
$results = $this->_loto(10,62);
$data["res"] = $results;
$this->load->view('simpleloto', $data);
return $results;
}
private function _loto($n = 0, $m = 0){
$results = array();
$counter = 0;
while($counter < $n){
$a = rand(1,$m);
if(!in_array($a, $results)){
$results[] = $a;
$counter++;
}
}
sort($results);
return $results;
}
private function _bingo_loto($start = 1, $end = 15, $n = 4){
$results = array();
$counter = 0;
while($counter < $n){
$a = rand($start,$end);
if(!in_array($a, $results)){
$results[] = $a;
$counter++;
}
}
sort($results);
return $results;
}
public function bingo(){
$results = array();
$results[] = $this->_bingo_loto(1,15,4);
$results[] = $this->_bingo_loto(16,30,4);
$results[] = $this->_bingo_loto(31,45,4);
$results[] = $this->_bingo_loto(46,60,4);
$results[] = $this->_bingo_loto(61,75,4);
$data["res"] = $results;
$this->load->view('bingoloto', $data);
return $results;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment