1. Go to this page and download the library: Download jstewmc/path library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$path = new Path('foo/bar/baz');
// get the index of the 'foo' segment
$path->getIndex('foo'); // returns 0
$path->getIndex('qux'); // returns false ('qux' does not exist)
// get the value of the 0-th (aka, 'first') segment
$path->getSegment(0); // returns 'foo'
$path->getSegment('first'); // returns 'foo'
$path->getSegment(999); // throws OutOfBoundsException
// does the path have a segment at the 1-st index?
$path->hasIndex(1); // returns true
$path->hasIndex(999); // returns false
// does the path have the given segments (at any index)?
$path->hasSegment('bar'); // returns true
$path->hassegment('qux'); // returns false
// does the path have the given segments (at the given indices)?
$path->hasSegment('foo', 0); // returns true
$path->hasSegment('foo', 'first'); // returns true
$path->hasSegment('foo', 1); // returns false ('foo' is 0-th)
$path->hasSegment('qux', 'last'); // returns false ('qux' does not exist)
$path = new Path('foo/bar/baz');
$path->slice(1);
echo $path; // prints "bar/baz"
$path->reverse();
echo $path; // prints "baz/bar"
$a = new Path('foo/bar/baz');
$b = $a->getSlice(1);
echo $a; // prints 'foo/bar/baz'
echo $b; // prints 'bar/baz'
$c = $a->getReverse();
echo $a; // prints 'foo/bar/baz'
echo $c; // prints 'baz/bar/foo'
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.