Mailinglisten-Archive |
Michael Schoenboeck wrote: > Hi reinhold, > > Also heut is DI und ich bin immer noch nich weiter :) $charset = array( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '_' ); function encode($number) { global $charset; $divisor = count($charset); $komponenten = array(); while ($number > $divisor) { $factors[] = $number % $divisor; $number = $number / $divisor; } $factors[] = floor($number); $result = ""; foreach ($factors as $factor) { $result .= $charset[$factor]; } return $result; } function decode($string) { global $charset; $result = 0; for ($i = 0; $i < strlen($string); $i++) { $factor = array_keys($charset, $string[$i]); $result += $factor[1] * pow(63, $i); } return $result; } Gruß André
php::bar PHP Wiki - Listenarchive