Skip to main content

basename

Function basename 

Source
pub fn basename<'a>(path: &'a [u8], suffix: &[u8]) -> &'a [u8] ⓘ
Expand description

PHP basename($path, $suffix) (Unix separators), as php_basename: the last component, trailing slashes ignored, with suffix removed when the component ends with it and is longer than it.

use php_std::path::basename;

assert_eq!(basename(b"/tmp/report.pdf/", b""), b"report.pdf");
assert_eq!(basename(b"/tmp/report.pdf", b".pdf"), b"report");
assert_eq!(basename(b"/", b""), b"");