Wallogit.com
2017 © Pedro Peláez
A PHP port of the furl library by gruns
Manipulating the url query is easy:, (*1)
$url = \Purl\Purl::fromString('http://www.google.com/?one=1&two=2');
unset($url['one']);
$url['three'] = 'foo';
echo $url->toString();
// http://www.google.com/?two=2&three=foo
````
Alternatively you can do the same like so:
```php
$url = \Purl\Purl::fromString('http://www.google.com/?one=1&two=2');
$url->getQuery()->add('three','foo')
->remove('one');
echo $url;
// http://www.google.com/?two=2&three=foo
Still one more way since the query has easy accessor methods in the Purl object:, (*2)
$url = \Purl\Purl::fromString('http://www.google.com/?one=1&two=2');
$url->add('three', 'foo')
->remove('one');
echo $url;
// http://www.google.com/?two=2&three=foo
You can add or remove from the path like so:, (*3)
$url = \Purl\Purl::fromString('http://www.google.com/path/?foo=2');
$url->getPath()->add('second-part');
// 'http://www.google.com/path/second-part/?foo=2'
$url->getPath()->remove('path');
// http://www.google.com/second-part/?foo=2
Fragments can be edited like so:, (*4)
$url = \Purl\Purl::fromString('http://www.google.com/path/?foo=2#fragment/foo?arg=one');
$url->getFragment()->getQuery()->remove('arg');
// http://www.google.com/path/?foo=2#fragment/foo
$url->getFragment()->getPath()->remove('foo');
// http://www.google.com/path/?foo=2#fragment