<?php
$array =
array(
// base10 => base58
'3429289555' => '6e31iZ',
'3368' => '215',
'74' => '2h',
'75' => '2i',
'94' => '2C',
'88' => '2w',
'195102' => 'ZZQ',
'1253576' => '7qDo',
'177' => '44',
'193' => '4k',
'195' => '4n'
);
foreach ($array as $base10 => $base58) {
echo 'base58_encode(\'', $base10, '\') => ', base58_encode($base10), "\n";
}
echo "\n";
foreach ($array as $base10 => $base58) {
echo 'base58_decode(\'', $base58, '\') => ', base58_decode($base58), "\n";
}
<?php
function base58_decode($num) {
$alphabet = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ';
$len = strlen($num);
$decoded = 0;
$multi = 1;
for ($i = $len - 1; $i >= 0; $i--) {
$decoded += $multi * strpos($alphabet, $num[$i]);
$multi = $multi * strlen($alphabet);
}
return $decoded;
}
<?php
function base58_encode($num) {
$alphabet = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ';
$base_count = strlen($alphabet);
$encoded = '';
while ($num >= $base_count) {
$div = $num / $base_count;
$mod = ($num - ($base_count * intval($div)));
$encoded = $alphabet[$mod] . $encoded;
$num = intval($div);
}
if ($num) {
$encoded = $alphabet[$num] . $encoded;
}
return $encoded;
}
Source
http://darklaunch.com/2009/08/07/base58-encode-and-decode-using-php-with-example-base58-encode-base58-decode