3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo{ public static $alphabet = 'ABCDEFGHIKLMNOPQRSTVXYZabcdefghiklmnopqrstvxyz'; public static function shorten($number) { $alphabet = self::$alphabet; $base = strlen($alphabet); $number = intval($number, 10); $shortened = ""; while ($number > 0) { $remainder = $number % $base; $shortened = $alphabet[$remainder] . $shortened; $number = (int) ($number / $base); } return $shortened; } public static function unshorten($string) { $alphabet = self::$alphabet; $base = strlen($alphabet); $length = strlen($string); $returnVal = 0; for ($i=$length-1; $i >= 0; --$i) { $ind = strpos($alphabet, $string[$i]); if ($ind === false) { return false; } $returnVal += (int)($ind * pow($base, $i)); } return $returnVal; } } $shortened = Foo::shorten(12343336363636636); echo $shortened . "\n"; var_dump(Foo::unshorten($shortened));
Output for git.master, git.master_jit, rfc.property-hooks
OSkMYgpOmE int(4376401713183091)

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
43.7 ms | 401 KiB | 8 Q