예제 #1
0
<?php

class Solution
{
    public $m = ['a' => ['top' => ' __ ', 'mid' => '|__|', 'bot' => '|  |'], 'b' => ['top' => ' __ ', 'mid' => '|__\\', 'bot' => '|__/'], 'c' => ['top' => ' __', 'mid' => '|  ', 'bot' => '|__'], 'd' => ['top' => ' __ ', 'mid' => '|  \\', 'bot' => '|__/'], 'e' => ['top' => ' __', 'mid' => '|_ ', 'bot' => '|__'], 'f' => ['top' => ' __ ', 'mid' => '|_  ', 'bot' => '|   '], 'g' => ['top' => ' __ ', 'mid' => '| _ ', 'bot' => '|__|'], 'h' => ['top' => '    ', 'mid' => '|__|', 'bot' => '|  |'], 'i' => ['top' => ' ', 'mid' => '|', 'bot' => '|'], 'j' => ['top' => '  - ', 'mid' => '  | ', 'bot' => ' _| '], 'k' => ['top' => '   ', 'mid' => '|_/', 'bot' => '|  \\'], 'l' => ['top' => '   ', 'mid' => '|  ', 'bot' => '|__'], 'm' => ['top' => '    ', 'mid' => '|\\/|', 'bot' => '|  |'], 'n' => ['top' => '    ', 'mid' => '|\\ |', 'bot' => '| \\|'], 'o' => ['top' => ' __ ', 'mid' => '|  |', 'bot' => '|__|'], 'p' => ['top' => ' __ ', 'mid' => '|__|', 'bot' => '|   '], 'r' => ['top' => ' __ ', 'mid' => '| _|', 'bot' => '|  \\'], 's' => ['top' => ' -- ', 'mid' => '|__ ', 'bot' => ' __|'], 't' => ['top' => '___', 'mid' => ' | ', 'bot' => ' | '], 'u' => ['top' => '    ', 'mid' => '|  |', 'bot' => '|__|'], 'w' => ['top' => '    ', 'mid' => '|  |', 'bot' => '|/\\|'], 'y' => ['top' => '   ', 'mid' => '\\_/', 'bot' => ' | '], 'z' => ['top' => ' __ ', 'mid' => '  / ', 'bot' => ' /_ ']];
    public $ip, $arr;
    function run($ip)
    {
        $this->ip = $ip;
        $this->arr = explode(" ", strtolower($this->ip));
        $this->printSeg('top');
        $this->printSeg('mid');
        $this->printSeg('bot');
    }
    function printSeg($seg)
    {
        foreach ($this->arr as $k => $w) {
            $chArr = str_split($w);
            foreach ($chArr as $c) {
                echo $this->m[$c][$seg];
                echo " ";
            }
            echo $k == count($this->arr) - 1 ? "\n" : "   ";
        }
    }
}
$i = new Solution();
$i->run('how are you');