Last active
April 19, 2017 11:04
-
-
Save Behinder/c6e405d818d123d2bb710540b6dbd3dc to your computer and use it in GitHub Desktop.
Converts time or number to its representation in emoji symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment