0

I need the best solution to get "token" from the URL.

Example of the URL (always the same structure):

https://steamcommunity.com/tradeoffer/new/?partner=123456789&token=qwerty1@

I want to get only qwerty1@ from this URL.

Which option is the best, safe and the faster to do this?

Regards.

2 Answers 2

2

You can use parse_url to get the querystring, then parse_str to get the token.

parse_str(parse_url(
   'https://steamcommunity.com/tradeoffer/new/?partner=123456789&token=qwerty1@',
   PHP_URL_QUERY
), $result);

echo $result['token']; // qwerty1@
Sign up to request clarification or add additional context in comments.

Comments

0

How about?

$arr = explode("=", $string);
echo end($arr); //prints "qwerty1@"

1 Comment

Code-only answers are not useful. Please explain how this helps / answers the question.

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.