-1

I have these urlencode from Postmant:

rq_uuid=e53473de-0483-44f5-91f0-2be74e58c277&rq_datetime
=2022-03-09 16:33:16&sender_id=TESS&receiver_id=SGRQWES

How can I convert this URLENCODE in an array in PHP so i will have an array like this :

array(
'rq_uuid' => 'e53473de-0483-44f5-91f0-2be74e58c277',
'rq_datetime' => '2022-03-09 16:33:16',
'sender_id' => 'TESS',
'receiver_id' => 'SGRQWES',
etc..
)
3
  • 2
    parse_str does exactly that. Commented Mar 9, 2022 at 10:32
  • 1
    Does this answer your question? Decode URL into an array rather than a string Commented Mar 9, 2022 at 10:55
  • For the record, Decode. If you wanted to Encode, you'd use http_build_query. As to why we don't have something like http_query_encode and http_query_decode, or http_parse_query for the "decoder" part, but instead we have http_build_query and parse_str for its counterpart (that for some reason must be used by reference), that's a question for the geniouses. Commented Mar 9, 2022 at 11:16

1 Answer 1

1

parse_str parses string as if it were the query string passed via a URL and sets variables in the current scope (or in the array if result is provided).

https://www.php.net/manual/en/function.parse-str.php

parse_str("rq_uuid=e53473de-0483-44f5-91f0-2be74e58c277&
=2022-03-09 16:33:16&sender_id=TESS&receiver_id=SGRQWES", $arr_params);

print "<pre>";

print_r ($arr_params);

print "</pre>";
Sign up to request clarification or add additional context in comments.

1 Comment

Its work..Tanks

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.