fallenangelbg / simpleurlparser
Parse url to a PHP array. Build an URL to be parsed by using an array
dev-main
2022-03-16 19:33 UTC
Requires
- php: >=7.0
- ext-ctype: *
This package is auto-updated.
Last update: 2025-06-17 02:08:56 UTC
README
This is a simple URL parser, which returns an array of results from url of kind /module/controller/param1:value/param2:value,value
The parser also returns Breadcrumb array, if provided with a names for it (either hard coded or via DB/any other array.
Usage:
Parse an URL to array
Example url: https://example.com/module/method1/param:1/param2:3,5,6/param3:test
use Fallenangelbg\SimpleUrlParser; $getUrlDetails = (new SimpleUrlParser)->parseUrlForResults();
Result:
Array ( ['url'] => 'module/method1/param:1/param2:3,5,6/param3:test' ['bread'] => Array ( ['Home'] => '/' ['module'] => 'module/' ['method1'] => 'method1/param:1/' ) ['module'] => 'module' ['switch'] => 'method1' ['params'] => Array ( ['param'] => 1 ['param2'] => Array ( [0] => 3 [1] => 5 [2] => 6 ) ['param3'] => 'test' ) )
Build URL from an array
use Fallenangelbg\SimpleUrlParser; $arrayToBeBuild = array ( ['module'] => 'module' ['switch'] => 'method1' ['params']['param'] = 1; ['params']['param2'] = Array ( [0] => 3 [1] => 5 [2] => 6 ) ); $getUrlDetails = (new SimpleUrlParser)->buildUrlByParams($arrayToBeBuild); echo $getUrlDetails;
Result
/module/method1/param:1/param2:3,5,6
Use it if you like :)