Example #1
0
function parseToCodePoints($word)
{
    $word_array = explode_telugu(json_encode($word));
    $i = 0;
    $logical_chars = array();
    $ch_buffer = array();
    while ($i < count($word_array)) {
        $current_ch = $word_array[$i++];
        $ch_buffer[count($ch_buffer)] = $current_ch;
        if ($i == count($word_array)) {
            $logical_chars[count($logical_chars)] = $ch_buffer;
            continue;
        }
        $next_ch = $word_array[$i];
        if (isDependent($next_ch)) {
            $ch_buffer[count($ch_buffer)] = $next_ch;
            $i++;
            $logical_chars[count($logical_chars)] = $ch_buffer;
            $ch_buffer = array();
            continue;
        }
        if (isHalant($current_ch)) {
            if (isConsonant($next_ch)) {
                if ($i < count($word_array)) {
                    continue;
                }
                $ch_buffer[count($ch_buffer)] = $current_ch;
            }
            $logical_chars[count($logical_chars)] = $ch_buffer;
            $ch_buffer = array();
            continue;
        } else {
            if (isConsonant($current_ch)) {
                if (isHalant($next_ch) || isDependentVowel($next_ch)) {
                    if ($i < count($word_array)) {
                        continue;
                    }
                    $ch_buffer[count($ch_buffer)] = $current_ch;
                }
                $logical_chars[count($logical_chars)] = $ch_buffer;
                $ch_buffer = array();
                continue;
            } else {
                if (isVowel($current_ch)) {
                    if (isDependentVowel($next_ch)) {
                        $ch_buffer[count($ch_buffer)] = $next_ch;
                        $i++;
                    }
                    $logical_chars[count($logical_chars)] = $ch_buffer;
                    $ch_buffer = array();
                    continue;
                }
            }
        }
        $logical_chars[count($logical_chars)] = $ch_buffer;
        $ch_buffer = array();
    }
    return $logical_chars;
}
Example #2
0
function getVowelIndex($word)
{
    $index = 0;
    for ($index = 0; $index < strlen($word); $index = $index + 1) {
        if (isVowel($word[$index])) {
            return $index;
        }
    }
}
Example #3
0
function make_pig_latin($string)
{
    $string = strtolower($string);
    $arrayChar = str_split($string);
    if (isVowel($arrayChar[0])) {
        return ucfirst($string . "yay");
    }
    $singleChar = array_shift($arrayChar);
    while (!isVowel($singleChar)) {
        $arrayChar[] = $singleChar;
        $singleChar = array_shift($arrayChar);
    }
    array_push($arrayChar, "ay");
    return ucfirst(implode($arrayChar));
}
Example #4
0
function ledBoard($text, $color)
{
    $text = strtoupper($text);
    if ($color == "random") {
        $color = generateRandomColor();
    }
    for ($i = 0; $i < strlen($text); $i++) {
        if (is_integer($text[$i])) {
            drawDigit($text[$i], $color);
        } elseif (isVowel($text[$i])) {
            drawVowel($text[$i], $color);
        } else {
            drawLetter($text[$i], $color);
        }
    }
}
Example #5
0
function ledBoard($text, $color)
{
    if ($color == "random") {
        $color = generateRandomHex();
        //YOU NEED TO IMPLEMET THIS FUNCTION
    }
    for ($i = 0; $i < strlen($text); $i++) {
        if (is_integer($text[$i])) {
            drawDigit($text[$i], $color);
        } elseif (isVowel($text[$i])) {
            //YOU NEED TO IMPLEMENT THE "isVowel" function!
            drawVowel($text[$i], $color);
        } else {
            drawLetter($text[$i], $color);
        }
    }
}
Example #6
0
function containsVowel($word)
{
    $len = strlen($word);
    for ($i = 0; $i < $len; $i++) {
        if (isVowel($word[$i])) {
            return true;
        }
    }
    return false;
}
Example #7
0
function makeName($n1, $n2)
{
    $coupleName = "";
    $firstHalf = "";
    $secondHalf = "";
    if (strlen($n1) < 4) {
        $firstHalf = $n1;
    } else {
        $vowIndex = 2;
        for ($i = strlen($n1) - 1; $i >= 2; $i--) {
            if (isVowel(substr($n1, $i, 1)) == TRUE) {
                $vowIndex = $i;
            }
        }
        $firstHalf = substr($n1, 0, $vowIndex);
    }
    if (strlen($n2) < 4) {
        $secondHalf = $n2;
    } else {
        $vowIndex = 0;
        for ($j = strlen($n2) - 1; $j >= 0; $j--) {
            if (isVowel(substr($n2, $j, 1)) == TRUE) {
                $vowIndex = $j;
            }
        }
        $secondHalf = substr($n2, $vowIndex, strlen($n2) - $vowIndex);
    }
    return $firstHalf . lcfirst($secondHalf);
}