Base36 Encoding/Decoding for Text with PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hknight
Forum Newbie
Posts: 13
Joined: Wed Aug 13, 2008 2:48 pm

Base36 Encoding/Decoding for Text with PHP

Post 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);
}

?>
Post Reply