Is there a encoding function in PHP which will encode strings and the resulting output will only contain letters and numbers? I would use base64 but that still has some stuff which is not numeric/alphanumeric
Any of the hash functions (md5, sha1, etc.) output will only consist of hexadecimal digits but that's not exactly 'encoding'.
You can use the basic md5 hash function which output only alphanumeric characters.
It really depends on your goal. Please explain in more detail what you want to achieve!
If you mean encoding in the sense of charset, then I doubt there is a charset that contains only alphanumeric members. base64 stands for a set of encodings limited to 64 chars, which is more than just the alphanumeric chars.
If you want to get rid of everything non-alphanumeric, I would suggest validating/filtering the content. You can use existing filter mechanism like in Zend_Validate or you can write your own filter. You can use Regular Expressions for this.
You could use base32 (code easy to google), which is sort of a standard alternative to base64. Or resort to bin2hex() and pack("H*",$hex)
to reverse. Hex encoding however leads to size doubling.
You could write your own base-62 encoder/decoder using a-z/A-Z/0-9. You'd need 3 digits for every ASCII character though, so not that efficient.
Short answer is no, base64 uses a reduced set of output chars compared with uuencode and was intended to solve most character converions issues - but still isn't url-safe (IIRC).
But the machanism is trivial and easily adapted - I'd suggest having a look at base32 encoding - same as base64 but using one less bit per input char to create the output (and hence a 32 char alphabet is all that's required) but using something different for the padding char ('=' is not url safe).
A quick google found this