Reputation: 684
I am trying to decode this base 64 encoded url string and it keeps returning blank why is that?
return strtr(base64_encode($url), '+/=', '-_,');
return base64_decode(strtr($url, '-_,', '+/='));
encoded url is this aHR0cDovL3Rlc3QuZ3J5cGhvbnRlYS5jb20vbWFnZW50by9zdG9yZS5odG1s
Upvotes: 2
Views: 2107
Reputation: 2085
Maybe convert your $url first to a $var, do your conversions, and then return the string, but I'm not convinced your strtr conversion is correct.
Upvotes: 1
Reputation: 855
Just cause your strtr in the decode is useless. Try just :
return base64_decode($url);
your url was :
That should do the job.
base64_decode(strtr($url, '-_,', '+/='));
With strstr you try to go to substring "-_,", and in your encoded url there is no such part. Then you try to base64_decode it, as strstr "fail" it return "". then you've got :
base64_decode("");
Upvotes: 2