Exemplo n.º 1
0
<?php 
function recurs($first, $last)
{
    if ($first % 2 != 0) {
        echo "{$first}<br>";
    }
    if ($first < $last) {
        $first++;
        recurs($first, $last);
    }
}
recurs(8, 16);
?>

<h1>7 </h1>
<?php 
function palindrom($string)
{
    $string = mb_strtolower($string);
    $reString = strrev($string);
    if ($reString == $string) {
        echo "TRUE";
    } else {
        echo "FALSE";
    }
}
palindrom("Civic");
?>
</body>
</html>
Exemplo n.º 2
0
<?php

$string = $_POST["string"];
function utf8_strrev($str)
{
    preg_match_all('/./us', $str, $ar);
    return join('', array_reverse($ar[0]));
}
function palindrom($string)
{
    $string = str_replace(" ", "", $string);
    if ($string == utf8_strrev($string)) {
        return true;
    } else {
        return false;
    }
}
if (palindrom($string) == true) {
    echo "Da, '" . $string . "' je palindrom";
} else {
    echo "Ne, '" . $string . "' ni palindrom";
}
Exemplo n.º 3
0
 function palindrom(&$n)
 {
     $length = strlen($n) - 1;
     if ($length === 0) {
         return "Yes";
     } elseif ($n[$length] === $n[0]) {
         $num = substr($n, 1, $length - 1);
         $n = $num;
         return palindrom($n);
     } else {
         return "No";
     }
 }
Exemplo n.º 4
0
function palindrom($str)
{
    static $a = 0;
    $z = strlen($str) - 1 - $a;
    static $res = true;
    if ($a < $z) {
        if ($str[$a] != $str[$z]) {
            $res *= false;
        }
        $a++;
        palindrom($str);
    }
    return $res;
}