The Text_PathArray class provides convenient access to "/path/sub/strings".
These strings can be accessed in various ways:
- by numeric index (e.g., index 1 of /pages/staff.html returns "staff.html")
- by variable name (e.g., index "id" of /pages/id/1 returns 1)
- using the slice method
Example Code:
require_once 'Text/PathArray.php';
$p = new Text_PathArray('/the/golden/path', '/');
echo $p->get(2); // prints 'path'
echo $p->get('golden'); // prints 'path'
echo $p->slice(1); // prints 'golden/path'
echo $p->slice(-2, 1); // prints 'golden'
echo $p->slice(-1); // prints 'path'
|