A: 

you can use for the encoding desired purpose sha1 functions check this: http://php.net/manual/en/function.sha1.php or you can use this link too

http://php.net/manual/en/function.crypt.php

Ankur Mukherjee
You can't decode sha1.
Amadan
How could I decode with these functions ?
Misha Moroshko
the answer was only for encoding purpose
Ankur Mukherjee
The OP specifically asked for a function that could be reversed. Hashing != Encoding != Encrypting. These are 3 distinct concepts that cannot be treated as interchangeable.
NullUserException
A: 

look at base64_encode and base64_decode

stillstanding
+1  A: 

You can use one of PHP's encryption functions (mcrypt) to encrypt your data, then use base64_encode to encode it into a string that can be sent as text.

NullUserException
A: 

Have a look at the Crypt_XXTEA Pear Package. You can encrypt/decrypt arbitrary Strings with it. It uses the XXTEA block cipher algorithm (see XXTEA at Wikipedia). If you want to have a "nice" format, you can additionally uuencode the encrpted output.

tweber
Why use that when you can use a proven scheme like Rijndael (AES) ? Not saying that XXTEA is bad, it's just not as battle-tested as AES.
NullUserException
A: 

Use something simple like rot13 and append a extra set of characters to each number. Yes this is a really weak form of encryption but it solves the question and you can make the output match what ever you want.

If the user wants something more complex then try using tweber's answer , but then you cant really control the length or randomness of the string output.

RC1140
A polyalphabetic cipher is a *terrible* idea.
NullUserException