web / url-search-params
A PHP implementation of URLSearchParams for handling query parameters easily.
Fund package maintenance!
Github
Patreon
Opencollective
Requires
- php: ^7.4 || ^8.0
README
A PHP implementation of URLSearchParams for handling query parameters easily.
Composer Installation
Installation is super-easy via Composer
composer require web/url-search-params
or add it by hand to your composer.json
file.
The Features of PHP URLSearchParams
Autoloading
use Web\URLSearchParams\URLSearchParams; require 'vendor/autoload.php';
Creating object without parameter
$usp = new URLSearchParams();
Creating object without '?' query string
$usp = new URLSearchParams('name=foo&id=123&age=12');
Creating object with '?' query string
$usp = new URLSearchParams('?name=foo&id=123&age=12');
Creating object query paire array with iterable [name, value]
$usp = new URLSearchParams([['name', 'foo'], ['id', 123], ['age', 12]]);
Creating object with associative array [key=>value] paire
$usp = new URLSearchParams(['name'=> 'foo', 'id'=> 123, 'age'=> 12]);
Creating object with object
$usp = new URLSearchParams(stdClass Object ( [name] => foo [id] => 123 [age] => 12 ));
entries()
$usp->entries();
tupples()
$usp->tupples();