Core Function HTTPMakeQuery
From Sputnik Wiki
HTTPMakeQuery( <array> )
Contents |
Description
Converts an array into a properly formatted HTTP query string for use with requests etc.
Parameters
array
The array to be converted into the query string.
Return Value
Success: Returns a properly formatted HTTP query string you can use safely.
Failure: Return null.
Remarks
None.
Example
// Make an array to be converted to a query string my $queryArray = array("Cat" => "Meow", "Dog" => "Woof", "Testy" => "Test&Hello"); // Convert it my $query = HTTPMakeQuery($queryArray); // Print the result say $query; // Prints: // Cat=Meow&Dog=Woof&Testy=Test%26Hello
How to convert from the HTTP query back to an array
// Make an array to be converted to a query string my $queryArray = array("Cat" => "Meow", "Dog" => "Woof", "Testy" => "Test&Hello"); // Convert it my $query = HTTPMakeQuery($queryArray); // Print the result say $query; // Decode the query my $arrayAgain = HTTPParseQuery($query); printr $arrayAgain; // Prints: // Cat=Meow&Dog=Woof&Testy=Test%26Hello // Array // ( // [Cat] => Meow // [Dog] => Woof // [Testy] => Test&Hello // )