prob / url-helper
A simple library for handling path of url and matching url easily
dev-master
2016-09-10 15:18 UTC
Requires
- php: >=5.4
Requires (Dev)
This package is not auto-updated.
Last update: 2024-11-23 20:04:33 UTC
README
A simple library for handling path of url and matching url easily
Usage
Simple path parser
Path class is separating url segments
<?php use Prob\Url\Path; $path = new Path('/apple/banana'); echo $path->seg(0); // apple echo $path->seg(1); // banana print_r($path->segments()); // Array ( 'apple', 'banana' )
Simple url matching
Matchar class is checking the url matching
<?php use Prob\Url\Matcher; $pathA = new Matcher('/apple'); print_r($pathA->match('/apple')); // Array ( ) print_r($pathA->match('/banana')); // false $pathB = new Matcher('/apple/banana'); print_r($pathB->match('/apple/banana')); // Array ( ) print_r($pathB->match('/apple')); // false print_r($pathB->match('/banana')); // false $pathC = new Matcher('/{board}/{post:int}'); print_r($pathC->match('/free/5')); // Array ( 'board' => 'free', 'post' => '5' ) print_r($pathC->match('/free')); // false print_r($pathC->match('/free/some')); // false
support type
- string
- int