// PASTE VIEWS
<?php
$botao="Sorteio";
$action="sorteio1";
?>
<!doctype - html5>
<html>
<head>
<title>Array</title>
<link rel="stylesheet" type="text/css" href="css/style_home.css">
<meta charset="utf-8">
</head>
<body>
<form name="frmsorteio" method="post" action="router.php?controller=sorteio&modo=<?php echo($action)?>">
<input class="botao1" type="submit" name="btn_prymari" value="<?php echo($botao)?>">
<table class="tabela">
<tr>
<td class="colunas"></td>
<td class="colunas"></td>
<td class="colunas"></td>
// ROUTER.PHP
<?php
$controller=$_GET['controller'];
$modo=$_GET['modo'];
switch($controller)
{
case 'sorteio':
require_once('controllers/sorteio_controller.php');
require_once('models/sorteio_class.php');
switch($modo)
{
case 'sorteio1':
$controller_sorteio = new ControllerSorteio();
$controller_sorteio->Sorteio1();
break;
}
}
?>
// PASTE CONTROLLERS
<?php
class ControllerSorteio{
public function Sorteio1(){
if($_SERVER['REQUEST_METHOD']=='POST'){
require_once('models/sorteio_class.php');
}
}
}
?>
// MODEL FOLDER
<?php
class CodeGen{
private $codes = array();
public function __construct($codes) {
$this->codes = $codes;
}
public function getRandomCode($min, $max){
$next = 60;
while (count($this->codes) < $next) {
$code = mt_rand($min, $max);
if (!in_array($code, $this->codes)) {
$this->codes[] = $code;
}
}
}
public function getLastCode(){
return ($this->codes);
}
}
$codes = array();
$CodeGen = new CodeGen($codes);
$CodeGen->getRandomCode(0, 60);
print_r $CodeGen->getLastCode();
?>