tags:

views:

31

answers:

3

Is there a base64_encode function that is URL safe in PHP?

It also needs to be decodable obviously.

Thanks for your help!

+1  A: 

Try this.

YouCanSam
Then swap arrays for reverse?
Cyclone
Yes. See also this comment: http://www.php.net/manual/en/function.base64-encode.php#63543 (The code is basically a translated version of Perl's MIME::Base64::URLSafe) :-)
YouCanSam
A: 

No. There isn't one built-in.

You can simply do this,

$encoded = strtr(base64_encode($data), '+/=', '-_.');
$data = base64_decode(strtr($encoded, '-_.', '+/='));
ZZ Coder
+2  A: 
urlencode(base64_encode($var));
Rook