3v4l.org

run code in 300+ PHP versions simultaneously
<?php // https://trello.com/jobs/windows-mobile-developer $alphabet = 'acdegilmnoprstuw'; // test data $hash = 680131659347; $string = 'leepadg'; $task_hash = 696005871397; echo sprintf('Hash of string «%s» is «%s».', $string, get_hash($alphabet, $string)) , PHP_EOL , sprintf('String of hash «%s» is «%s».', $hash, get_string($alphabet, $hash)) , PHP_EOL , sprintf('Solution for hash «%s» is «%s».', $task_hash, get_string($alphabet, $task_hash)) ; function get_hash($alphabet, $string) { $h = 7; $len = strlen($string); for($i = 0; $i < $len; $i++) { $h = ($h * 37 + strpos($alphabet, $string[$i])); } return $h; } function get_string($alphabet, $hash) { $result = ''; $len = strlen($alphabet); while ($hash > 7) { for ($i = 0; $i < $len; $i++) { $newres = ($hash - $i) / 37; if (is_int($newres)) { $result .= $alphabet[$i]; $hash = $newres; break; } } } return strrev($result); }
Output for git.master, git.master_jit, rfc.property-hooks
Hash of string «leepadg» is «680131659347». String of hash «680131659347» is «leepadg». Solution for hash «696005871397» is «spartan».

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:
55.69 ms | 401 KiB | 8 Q