This is a discussion on Re: One liner for finding a file within the PHP Language forums, part of the PHP Programming Forums category; chdir( '/directory/to/search' ); $a_strFilenames = glob( '*footer*' ); if( count( $a_strFilenames ) == 1 ) { print "Found '" . $a_strFilenames[ 0 ] . "'\n"; } ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
chdir( '/directory/to/search' ); $a_strFilenames = glob( '*footer*' ); if( count( $a_strFilenames ) == 1 ) { print "Found '" . $a_strFilenames[ 0 ] . "'\n"; } else { print "Something's wrong: no file found, or more than one match.\n"; } --- Steve |
|
|||
|
"Steve" <googlespam@nastysoft.com> wrote in message
news:cfdej1$171@odak26.prod.google.com... > > > chdir( '/directory/to/search' ); > > $a_strFilenames = glob( '*footer*' ); > > if( count( $a_strFilenames ) == 1 ) > { > print "Found '" . $a_strFilenames[ 0 ] . "'\n"; > } > else > { > print "Something's wrong: no file found, or more than one match.\n"; > } > > > --- > Steve The OP wants the complete path, so this would work better: list($path) = glob('/directory/to/search/*footer*'); |