Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

SimonAngatia's avatar

How to get full URL without sorting query parameters

I want to extract the query part of a URL, this is my URL for example http://mywebsite.com/tvbet/response?action=balance&refId=0&accountId=1&gameId=100138&clientType=desktop&currency=TRY&isBonus=False&username=Yonetim&hash=iobVJKHFhhgjvfcVJHIKVGYFG

To do that, I am using laravel helper url()->full() . Now the problem is that it is re-arranging the parameters like this:

http://mywebsite.com/tvbet/response?accountId=1&action=balance&clientType=desktop&currency=TRY&gameId=100138&hash=iobVJKHFhhgjvfcVJHIKVGYFG&isBonus=False&refId=0&username=Yonetim

What should I do so that I get the full url without sorting the parameters?

0 likes
4 replies
Sinnbeck's avatar

use url parse to get the parts

$parts = parse_url(' http://mywebsite.com/tvbet/response?action=balance&refId=0&accountId=1&gameId=100138&clientType=desktop&currency=TRY&isBonus=False&username=Yonetim&hash=iobVJKHFhhgjvfcVJHIKVGYFG');
dd($parts['query']):
SimonAngatia's avatar

Yes, I am doing that. My problem is that url()->full(); is sorting the parameters yet I want the query part to be as it is without being sorted

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

Ok try this then

$query = $_SERVER['QUERY_STRING'];

Please or to participate in this conversation.