Page 1 of 1

Base36 Encoding/Decoding for Text with PHP

Posted: Tue Nov 09, 2010 3:46 pm
by hknight
I want functions similar to base64_encode() and base64_decode() however only numbers and lowercase letters should be used.

I want to be able to convert a string of text or binary data into a series of numbers and lowercase letters.

My function works with numbers but not with text or binary data.

Code: Select all

<?php

echo base36_encode('555555555');
echo '<hr />';
echo base36_encode('Hello World, this is a test!');

function base36_encode($base10){
    return base_convert($base10,10,36);
}
 
function base36_decode($base36){
    return base_convert($base36,36,10);
}

?>