-
Notifications
You must be signed in to change notification settings - Fork 0
/
utility.php
36 lines (30 loc) · 873 Bytes
/
utility.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
class Utility {
public static function getShortcode ($integer)
{
$base = 'abcdefghjkmnpqrstwxz23456789';
$length = strlen($base);
$out1='';
while($integer > $length - 1)
{
$out1 = $base[fmod($integer, $length)] . $out1;
$integer = floor( $integer / $length );
}
$shorturl=$base[$integer] . $out1;
return $shorturl;
}
public static function getDatetime($string)
{
$base = 'abcdefghjkmnpqrstwxz23456789';
$length = strlen($base);
$size = strlen($string) - 1;
$string = str_split($string);
$out = strpos($base, array_pop($string));
foreach($string as $i => $char)
{
$out += strpos($base, $char) * pow($length, $size - $i);
}
return $out;
}
}
?>