web/url-search-params

A PHP implementation of URLSearchParams for handling query parameters easily.

v1.0.0 2024-11-17 17:33 UTC

This package is auto-updated.

Last update: 2024-11-17 17:34:22 UTC


README

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