Skip to content

Latest commit

 

History

History
83 lines (62 loc) · 2.3 KB

README.md

File metadata and controls

83 lines (62 loc) · 2.3 KB

PHP URLSearchParams

A PHP implementation of URLSearchParams for handling query parameters easily.

Total Downloads Latest Version

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();

Resources