Skip to main content

pathinfo_extension

Function pathinfo_extension 

Source
pub fn pathinfo_extension(path: &[u8]) -> &[u8] ⓘ
Expand description

PHP pathinfo($path, PATHINFO_EXTENSION): what follows the last . of basename, or an empty string when it has no ..

use php_std::path::pathinfo_extension;

assert_eq!(pathinfo_extension(b"server/pages/index.html"), b"html");
assert_eq!(pathinfo_extension(b"archive.tar.gz"), b"gz");
assert_eq!(pathinfo_extension(b"Dockerfile"), b"");
assert_eq!(pathinfo_extension(b".env"), b"env");
var_dump(pathinfo('server/pages/index.html', PATHINFO_EXTENSION)); // string(4) "html"
var_dump(pathinfo('Dockerfile', PATHINFO_EXTENSION));              // string(0) ""