- substr: documentation ( source)
- ord: documentation ( source)
<?php
function getCharacter($index) {
$chars = "0123456789ABCDEFGHIJKLMOPQRSTUVWabcdefghijklmnopqrstuvw";
$c = ord(substr($chars, $index % strlen($chars)));
//return ord(substr($chars, ($index << $c) % strlen($chars)));
return ($index << $c) & 0xffffff;
}
function main() {
$array = array(176, 52, 608, 855);
foreach ($array as $value) {
echo "$value: " . getCharacter($value) . "\n";
}
}
main();