Documentation for crwlr / url (v2.0)

Attention: You're currently viewing the documentation for v2.0 of the url package.
This is not the latest version of the package.
If you didn't navigate to this version intentionally, you can click here to switch to the latest version.

Query String

Getting The Query as an Array

If you're after the query of a url you may want to get it as an array. Don't worry, nothing easier than that:

$url = Url::parse('');


array(2) {
  string(3) "baz"
  string(5) "value"

And the same method can be used to set the whole query string from an array:

$url = Url::parse('');
$url->queryArray(['param' => 'value', 'yo' => 'lo', 'crwlr' => 'url']);


string(55) ""

Advanced Query String API

The queryString() method returns an instance of the Query class, that is part of the separate query string package. You can find the docs for this class here. Everything documented there can be used on the object returned by the queryString() method and of course it automatically changes in the full URL string representation.

A quick example:

$url = Url::parse('[number]=3&page[size]=25');

    ->set('number', '4');


// string(68) ""