Types:
$str = 'folder';
$str = 'folder/subfolder';
Desired Result:
$str = '';
$str = 'subfolder';
Attempt:
// Works for "folder/subfolder"
$str = preg_replace('/.*?\//i', '', $str);
NOTE: “folder” is unknown.
Any help is appreciated, thank you!
should work. This removes non-slash characters at the start of the string (a folder name) and a slash after that (or not, if the folder name is isolated).