0

I have a curl function which outputs the following text from an api. number=1&id=731&name=test&value=6311

How could I make a variable which will store one of these values in the text such as I want to make a variable called $name which will have the 'test' value from the output of the api. I saw different things such as in json you can use $variable['name'] but it doesn't seem to work like this.. help

Athena
  • 3,200
  • 3
  • 27
  • 35
trevorrww
  • 35
  • 5

1 Answers1

0

Check this:

Parse query string into an array

Use parse_str function, it looks like:

 $get_string = "number=1&id=731&name=test&value=6311";

 parse_str($get_string, $get_array);

 print_r($get_array);
Community
  • 1
  • 1
Vallabha Vamaravelli
  • 1,153
  • 1
  • 9
  • 15