$fileRef = '/path/to/myfile.txt'; $fileInfo = t3lib_div::split_fileref($fileRef); echo $fileInfo['path']; // output: /path/to/ echo $fileInfo['file']; // output: myfile echo $fileInfo['suffix']; // output: txt
$url = 'https://www.example.com/path/to/myfile.html'; $fileInfo = t3lib_div::split_fileref($url); echo $fileInfo['path']; // output: /path/to/ echo $fileInfo['file']; // output: myfile echo $fileInfo['suffix']; // output: htmlIn this example, we split a URL 'https://www.example.com/path/to/myfile.html' into its components using the split_fileref function. The resulting array is then used to access the path, file name and extension. Package library: The t3lib_div function is part of the TYPO3 CMS core library.