Path · Mecha CMS

File/URL path helpers.

$path::X()

Author: Taufik Nurrohman · 207 Views

Tweet

Get file extension from a file path.

Path::X($path, $fail = false);

Example:

$test_1 = Path::X('foo\bar\baz.qux');
$test_2 = Path::X('foo\bar\baz', 'txt');
$test_3 = Path::X('foo\bar\baz.QUX');

Result:

$test_1 = 'qux';
$test_2 = 'txt';
$test_3 = 'qux';