I\'m looking for the name of the PHP function to build a query string from an array of key value pairs. Please note, I am looking for the built in PHP function to d
As this question is quite old and for PHP, here is a way to do it in the (currently) very popular PHP framework Laravel.
To encode the query string for a path in your application, give your routes names and then use the route() helper function like so:
route('documents.list.', ['foo' => 'bar']);
The result will look something like:
http://localhost/documents/list?foo=bar
Also be aware that if your route has any path segment parameters e.g. /documents/{id}
, then make sure you pass an id
argument to the route()
parameters too, otherwise it will default to using the value of the first parameter.