Kevin Houde Kevin Houde - 1 month ago 10
PHP Question

Remove slash ("/") with encode with codeigniter

I have to encode a part of my code to send by email and I need to decode it after this when the user click on my link. But the problem was the encode function put slash ("/") ex:

$email_info = $this->encrypt->encode($email.':'.$token);
///if I ECHO $email_info I got this --> BmJXYlIlBQxbOwRsUiYEYQcxUBRXbgA/VXZQOg40VW4GPVB9AmRUPgVnVT9QNQNsC3cFagI3Bz4DZgViXD8CMVRuVToOMVYwAjAHdQk4A3IGbldyUj4FJVsrBHBSJQR8BzpQbVcxAGNValBuDmdVfQY5UCUCflQ1BXJVdA%3D%3D


In my other page , I do this:
$key = $this->uri->segment(3);


So I only get this part
BmJXYlIlBQxbOwRsUiYEYQcxUBRXbgA
because of the / after the letter A
so my next part of my code wont work ( my decode function
$array_info = $this->encrypt->decode($key);
)

I try a lot of things like
urlencode()
,
rawencode()
, and I always got "/" on my url ,

How can I encode this "/" ?

Answer

Try a raw replace:

str_replace("/", "%2F", $email_info)

or do try

rawurlencode