Skip to content

Instantly share code, notes, and snippets.

@toshimaru
Created September 24, 2012 09:34
Show Gist options
  • Save toshimaru/3775127 to your computer and use it in GitHub Desktop.
Save toshimaru/3775127 to your computer and use it in GitHub Desktop.
urlsafe base64 function.
<?php
function base64_urlsafe_encode($val) {
$val = base64_encode($val);
return str_replace(array('+', '/', '='), array('_', '-', '.'), $val);
}
function base64_urlsafe_decode($val) {
$val = str_replace(array('_','-', '.'), array('+', '/', '='), $val);
return base64_decode($val);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment