
- PHP Tutorial
- PHP - Home
- PHP - Introduction
- PHP - Environment Setup
- PHP - Syntax Overview
- PHP - Variable Types
- PHP - Constants
- PHP - Operator Types
- PHP - Decision Making
- PHP - Loop Types
- PHP - Arrays
- PHP - Strings
- PHP - Web Concepts
- PHP - GET & POST
- PHP - File Inclusion
- PHP - Files & I/O
- PHP - Functions
- PHP - Cookies
- PHP - Sessions
- PHP - Sending Emails
- PHP - File Uploading
- PHP - Coding Standard
- Advanced PHP
- PHP - Predefined Variables
- PHP - Regular Expression
- PHP - Error Handling
- PHP - Bugs Debugging
- PHP - Date & Time
- PHP & MySQL
- PHP & AJAX
- PHP & XML
- PHP - Object Oriented
- PHP - For C Developers
- PHP - For PERL Developers
- PHP Form Examples
- PHP - Form Introduction
- PHP - Validation Example
- PHP - Complete Form
- PHP login Examples
- PHP - Login Example
- PHP - Facebook Login
- PHP - Paypal Integration
- PHP - MySQL Login
- PHP AJAX Examples
- PHP - AJAX Search
- PHP - AJAX XML Parser
- PHP - AJAX Auto Complete Search
- PHP - AJAX RSS Feed Example
- PHP XML Example
- PHP - XML Introduction
- PHP - Simple XML
- PHP - Simple XML GET
- PHP - SAX Parser Example
- PHP - DOM Parser Example
- PHP Frame Works
- PHP - Frame Works
- PHP - Core PHP vs Frame Works
- PHP Design Patterns
- PHP - Design Patterns
- PHP Function Reference
- PHP - Built-In Functions
- PHP Useful Resources
- PHP - Questions & Answers
- PHP - Useful Resources
- PHP - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
PHP - Function glob()
The glob() function can return an array containing file names or directories matching the specified pattern. This function can return an array containing matching files/directories or false on failure.
Syntax
array glob ( string $pattern [, int $flags = 0 ] )
The glob() function can search for all pathnames matching patterns according to the rules used by glob() function, which is similar to rules used by common shells.
Example-1
<?php print_r(glob("/PhpProject/php/*.txt")); ?>
Output
Array ( [0] => /PhpProject/php/phptest1.txt [1] => /PhpProject/php/phptest2.txt [2] => /PhpProject/php/phptest3.txt [3] => /PhpProject/php/phptest4.txt [4] => /PhpProject/php/phptest5.txt [5] => /PhpProject/php/phptest6.txt [6] => /PhpProject/php/phptest7.txt [7] => /PhpProject/php/phptest8.txt [8] => /PhpProject/php/phptest9.txt [9] => /PhpProject/php/phptest10.txt )
Example-2
<?php foreach(glob("/PhpProject/php/*.txt") as $filename) { echo "$filename size " . filesize($filename) . "\n"; } ?>
Output
/PhpProject/php/phptest1.txt size 223 /PhpProject/php/phptest2.txt size 254 /PhpProject/php/phptest3.txt size 275 /PhpProject/php/phptest4.txt size 214 /PhpProject/php/phptest5.txt size 269 /PhpProject/php/phptest6.txt size 235 /PhpProject/php/phptest7.txt size 287 /PhpProject/php/phptest8.txt size 298 /PhpProject/php/phptest9.txt size 209 /PhpProject/php/phptest10.txt size 265
php_function_reference.htm
Advertisements