0

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?

1
  • 2
    If everything is being sent back encoded, run urldecode() on them before exploding. Commented Mar 9, 2011 at 5:27

3 Answers 3

1

You can use this method

$output = explode('|', urldecode($_POST['custom']));
Sign up to request clarification or add additional context in comments.

1 Comment

you mean I don't have to urldecode it? PHP does it automatically? oops, never mind I did not read it right.
0

Try to use urldecode

echo urldecode('5%7C3');

and after this use explode function.

Comments

0

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);
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.