About urLdecode and rawurldecode

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
receiver
Forum Newbie
Posts: 4
Joined: Tue May 19, 2009 10:18 pm

About urLdecode and rawurldecode

Post by receiver »

I have tried following coding:

php Code:

Code: Select all

<?php echo urlencode($action[0]).'<br/>' ;?>
<?php echo urldecode($action[0]).'<br/>' ;?>
<?php echo urlencode(rawurldecode($action[0])).'<br/>' ;?>
<?php echo rawurldecode(urlencode($action[0])).'<br/>';?>
<?php echo rawurldecode($action[0]).'<br/>';?>
<?php echo $action[0].'<br/>'?>
<?php echo urldecode($action[0]).'<br/>' ;?>
<?php echo urldecode(rawurldecode($action[0])).'<br/>' ;?>
<?php echo rawurldecode(urldecode($action[0])).'<br/>' ;?>
<?php echo urldecode(rawurlencode($action[0])).'<br/>' ;?>
<?php echo urldecode(rawurldecode($action[0])).'<br/>' ;?>
<?php echo rawurldecode($action[0]).'<br/>' ;?>

the following are the outputs:
cpl198+publisher%40gmail.com
cpl198 publisher@gmail.com
cpl198+publisher%40gmail.com
cpl198+publisher@gmail.com
cpl198 publisher@gmail.com
cpl198 publisher@gmail.com
cpl198 publisher@gmail.com
cpl198 publisher@gmail.com
cpl198 publisher@gmail.com
cpl198 publisher@gmail.com
cpl198 publisher@gmail.com
cpl198 publisher@gmail.com

I want it to be display as cpl198%2B@gmail.com. $action[0] is a email address that from url using GET method.

Do you have any idea for solving this question?

Thank you.
Last edited by Benjamin on Thu May 21, 2009 10:04 pm, edited 1 time in total.
Reason: Changed code type from text to php.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: About urLdecode and rawurldecode

Post by Christopher »

So you want to replace ' publisher' with '%2B' ? Use str_replace().
(#10850)
receiver
Forum Newbie
Posts: 4
Joined: Tue May 19, 2009 10:18 pm

Re: About urLdecode and rawurldecode

Post by receiver »

No. I wish to display as cpl198%2Bpublisher@gmail.com. Apparently, it appears as cpl198 publisher@gmail.com
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: About urLdecode and rawurldecode

Post by Christopher »

You could use str_replace() for that. See the manual.
(#10850)
Post Reply