What are some methods in PHP to extract only the folder name from a path without the full path?

When working with file paths in PHP, you may need to extract just the folder name from a given path without the full path included. One way to achieve this is by using the `basename()` function in PHP, which returns the trailing name component of a path. By passing the path to `basename()` and setting the second parameter to `dirname`, you can extract just the folder name.

$path = '/path/to/your/folder/file.txt';
$folderName = basename(dirname($path));
echo $folderName; // Outputs 'folder'