I am working on a PayPal Subscription IPN. The custom variable I send to PayPal looks like this:

5|3

When PayPal send this back to me, it is urlencoded and looks like this:

5%7C3

If I want to use the explode function, can I do the following?

$custom = $_POST['custom'];
if(isset($custom))
{
list($id_1, $id_2) = explode('|', $custom);
}

or like this?

$custom = $_POST['custom'];
if(isset($custom))
{
list($id_1, $id_2) = explode('%7C', $custom);
}

How can I do this properly? Thank you!

share|improve this question
2  
If everything is being sent back encoded, run urldecode() on them before exploding. – BoltClock Mar 9 '11 at 5:27
feedback

3 Answers

up vote 1 down vote accepted

u can use this method

$output = explode('|', urldecode($_POST['custom']));
share|improve this answer
you mean I don't have to urldecode it? PHP does it automatically? oops, never mind I did not read it right. – saburius Mar 9 '11 at 5:35
@saburius i update my answer,please have a look – diEcho Mar 9 '11 at 5:37
feedback

You can pass it through urldecode() first, then explode it by the absolute value delimiter

$custom = urldecode($_POST['custom']);
if($custom!="")
{
list($id_1, $id_2) = explode('|', $custom);
}
share|improve this answer
feedback

Try to use urldecode

echo urldecode('5%7C3');

and after this use explode function.

share|improve this answer
feedback

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.