-2

I know this is a basic question but I can't find it or even thing what it might be called.

But is there a function to easily decode strings with multiple vars like this?

$vars = 'status=true&stackoverflow=great&apple=red&orange=orange';

How would I get the value of "apple" with a function?

Something like echo '$vars.apple'; etc...

Papa De Beau
  • 3,744
  • 18
  • 79
  • 137

1 Answers1

0

You should look into parse_url

mixed parse_url ( string $url [, int $component = -1 ] )

This function parses a URL and returns an associative array containing any of the various components of the URL that are present. The values of the array elements are not URL decoded.

This function is not meant to validate the given URL, it only breaks it up into the above listed parts. Partial URLs are also accepted, parse_url() tries its best to parse them correctly

source

hexYeah
  • 1,040
  • 2
  • 14
  • 24