PHP code example of kumatch / path

1. Go to this page and download the library: Download kumatch/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/ */

    

kumatch / path example snippets



use Kumatch\Path;

Path.normalize("/foo//bar///baz/qux//../../quux");
// returns "/foo/bar/quux"

Path.normalize("foo/bar/../bar");
// returns "foo/bar"

Path.normalize("/foo/../../");
// returns "/"

Path.join("foo", "bar", "baz");
// returns "foo/bar/baz"

Path.join("/foo", "bar", "baz/qux", "quux");
// returns "/foo/bar/baz/qux/quux"

Path.join("/foo", "bar", "baz/qux", "../..");
// returns "/foo/bar"

Path.dirname("/foo/bar/baz");
// returns "foo/bar"

Path.dirname("foo/bar/baz/../qux");
// returns "foo/bar/baz/.."

Path.basename("/path/to/foo.txt");
// returns "foo.txt"

Path.basename("/path/to/foo.txt", ".txt");
// returns "foo"

Path.basename("/path/to/foo.txt", "oo.txt");
// returns "f"

Path.basename("/path/to/foo.txt", "foo.txt");
// returns "foo.txt"

Path.extname("/path/to/foo.txt");
// returns ".txt"

Path.extname("foo.bar.jpeg");
// returns ".jpeg"

Path.extname("foo.");
// returns "."

Path.extname("foo");
// returns ""