Answers for "Write a function that encodes a string into 1337 without using strlen"

0

Write a function that encodes a string into 1337 without using strlen

class Leetify
{
    private $english = array("a", "e", "s", "S", "A", "o", "O", "t", "l", "ph", "y", "H", "W", "M", "D", "V", "x"); 
    private $leet = array("4", "3", "z", "Z", "4", "0", "0", "+", "1", "f", "j", "|-|", "\\/\\/", "|\\/|", "|)", "\\/", "><");
    function encode($string)
    {
        $result = '';
        for ($i = 0; $i < strlen($string); $i++) 
        {
            $char = $string[$i];

            if (false !== ($pos = array_search($char, $this->english))) 
            {
                $char = $this->leet[$pos]; //Change the char to l33t.
            }
            $result .= $char;
        }
        return $result; 
    } 

    function decode($string) 
    {
        // Just reverse the above.
    }
}
Posted by: Guest on February-18-2021

Code answers related to "Write a function that encodes a string into 1337 without using strlen"

Browse Popular Code Answers by Language