<?php
require "urlbuilder.class.php";
$urlbuilder = urlbuilder::CreateNew();
//Supports chaining to make things easier, order does NOT matter
$urlbuilder->BaseURL("http://example.com/")->Set("year", "2015", false)->Set("slug", "news-slug", true)->Prefix("news")->Seperator("/")->Suffix("/");
//Gets the array used internally for storing the data
var_dump($urlbuilder->GetArray());
//Builds the URL
var_dump($urlbuilder->GetLink());
//Build a rewrite rule for the link, NOTE: you will need to add the file name to the url rule
var_dump($urlbuilder->GetRewriteRule());
//Example Output
/*
array (size=5)
'BaseURL' => string 'http://example.com/' (length=19)
'Params' =>
array (size=2)
'year' =>
array (size=2)
'Value' => string '2015' (length=4)
'HideKey' => boolean false
'slug' =>
array (size=2)
'Value' => string 'news-slug' (length=9)
'HideKey' => boolean true
'Prefix' => string 'news' (length=4)
'Seperator' => string '/' (length=1)
'Suffix' => string '/' (length=1)
string 'http://example.com/news/year/2015/news-slug/' (length=44)
string 'news/year/([^/]*)/([^/]*)\/$ ?year=$1&slug=$1' (length=45)
*/
?>
|