DeveloperBreeze

File Listing with glob()

$directoryPath = '/home/user/projects/using-glob';
$fileExtension = 'jpg';

// View files with the specified extension
foreach (glob($directoryPath . '/*.' . $fileExtension) as $image) {
    echo basename($image) . "\n";
}

// View all files without a specified extension
foreach (glob($directoryPath . '/*') as $file) {
    echo basename($file) . "\n";
}

Continue Reading

Discover more amazing content handpicked just for you

Code
python

Batch File Renaming Using os Module

No preview available for this content.

Jan 26, 2024
Read More
Code
python

List Files in a Directory Using os Module

No preview available for this content.

Jan 26, 2024
Read More

Discussion 0

Please sign in to join the discussion.

No comments yet. Start the discussion!