Return to Snippet

Revision: 72054
at April 19, 2017 21:06 by beyo


Initial Code
function convertNumberToEmoji($cyfra)
{

switch ($cyfra) {
    case '0':
        return "\u{30}\u{FE0F}\u{20E3}";
                break;
    case '1':
        return "\u{31}\u{FE0F}\u{20E3}";
                break;
    case '2':
        return "\u{32}\u{FE0F}\u{20E3}";
                break;
    case '3':
        return "\u{33}\u{FE0F}\u{20E3}";
                break;
    case '4':
        return "\u{34}\u{FE0F}\u{20E3}";
                break;
    case '5':
        return "\u{35}\u{FE0F}\u{20E3}";
                break;
    case '6':
        return "\u{36}\u{FE0F}\u{20E3}";
                break;
    case '7':
        return "\u{37}\u{FE0F}\u{20E3}";
                break;
    case '8':
        return "\u{38}\u{FE0F}\u{20E3}";
                break;
    case '9':
        return "\u{39}\u{FE0F}\u{20E3}";
                break;
    default:
        return " ";
        break;
    }
}

function convertTimeToEmoji($str)
{
    # Supported time format {hh}:{mm}
$array = str_split($str,1);
$result=array();
foreach ($array as $char) {
    $result[] = convertNumberToEmoji($char);
}
$emojistring = implode("",$result);
return $emojistring;

}
function convertTimeToClockIcon($str)
{
  # Supported time format {hh}:{mm}
  #
$timesbefore=["00:00","00:30","1:00","1:30","2:00","2:30","3:00","3:30","4:00","4:30","5:00","5:30","6:00","6:30","7:00","7:30","8:00","8:30","9:00","9:30","10:00","10:30","11:00","11:30"];
$timesafter =[
"12:00" => "\u{1F55B}",
"12:30" => "\u{1F567}",
"13:00" => "\u{1F550}",
"13:30" => "\u{1F55C}",
"14:00" => "\u{1F551}",
"14:30" => "\u{1F55D}",
"15:00" => "\u{1F552}",
"15:30" => "\u{1F55E}",
"16:00" => "\u{1F553}",
"16:30" => "\u{1F55F}",
"17:00" => "\u{1F554}",
"17:30" => "\u{1F560}",
"18:00" => "\u{1F555}",
"18:30" => "\u{1F561}",
"19:00" => "\u{1F556}",
"19:30" => "\u{1F562}",
"20:00" => "\u{1F557}",
"20:30" => "\u{1F563}",
"21:00" => "\u{1F558}",
"21:30" => "\u{1F564}",
"22:00" => "\u{1F559}",
"22:30" => "\u{1F565}",
"23:00" => "\u{1F55A}",
"23:30" => "\u{1F566}"
];
if (in_array($str, $timesbefore)) {

foreach (array_values($timesbefore) as $i => $value) {
    if ($str == $value) {
        $allkeys = array_keys($timesafter);
        return $timesafter[$allkeys[$i]];
    }
}
} else {
    if (array_key_exists($str,$timesafter)) {
        return $timesafter[$str];
    }
}
}

Initial URL

                                

Initial Description
Simple converter of string with name of few countries and time to proper emoji representation in unicode

Initial Title
Convert string to emojis

Initial Tags

                                

Initial Language
HTML