Code: Select all
<?php
class echolink_zkr_volby{
public $_prirazene = array();
public $_dbHandler;
public function __construct($handler)
{
$this->_dbHandler = $handler;
}
/* Start - Logická metoda */
public function znak2($znak)
{
$number = array(
"a" => 2, "b" => 22, "c" => 222,
"d" => 3, "e" => 33, "f" => 333,
"g" => 4, "h" => 44, "i" => 444,
"j" => 5, "k" => 55, "l" => 555,
"m" => 6, "n" => 66, "o" => 666,
"p" => 7, "q" => 77, "r" => 777, "s" => 7777,
"t" => 8, "u" => 88, "v" => 888,
"w" => 9, "x" => 99, "y" => 999, "z" => 9999);
return $number[$znak];
}
public function prevod_number2($znacka,$ints)
{
if($ints == 2)
{
$zn .= 0;
}
for ($i = 0; $i < $ints; $i++)
{
$zn .= $this->znak2($znacka[$i]);
}
/*
if($ints == 1)
{
$zn .= $zn.$zn;
}
*/
return $zn;
}
public function znacka2($znacka)
{
$znacka = substr(strtolower($znacka), 3);
$pocet_znaku = strlen($znacka);
$pss = "A".$this->prevod_number2($znacka,$pocet_znaku);
return $pss;
}
/* END - Logická metoda */
//----------------------------------------------------------------------------------------
/* Start - Zkrácena metoda */
public function znak($znak)
{
$number = array(
"a" => 2, "b" => 2, "c" => 2,
"d" => 3, "e" => 3, "f" => 3,
"g" => 4, "h" => 4, "i" => 4,
"j" => 5, "k" => 5, "l" => 5,
"m" => 6, "n" => 6, "o" => 6,
"p" => 7, "q" => 7, "r" => 7, "s" => 7,
"t" => 8, "u" => 8, "v" => 8,
"w" => 9, "x" => 9, "y" => 9, "z" => 9);
return $number[$znak];
}
public function prevod_number($znacka,$ints)
{
$eask = explode("-",$znacka);
$asd = count($eask);
if($asd >=2)
{
$znacka = $eask[0];
$ints = strlen($znacka);
}
if($ints == 2)
{
$zn .= 0;
}
for ($i = 0; $i < $ints; $i++)
{
$zn .= $this->znak($znacka[$i]);
}
if($ints == 1)
{
$zn .= $zn.$zn;
}
return $zn;
}
public function znacka($znacka)
{
$znacka = substr(strtolower($znacka), 3);
$pocet_znaku = strlen($znacka);
$ps = $this->prevod_number($znacka,$pocet_znaku);
return $ps;
}
/* END - Zkrácena metoda */
}
--------------------------------------------------------
znacka("jn89OD");
Zkrácena volba
--------------------------------------------------------
znacka2("jn89OD");
Logická volba