Re: [PHP] Reg Ex

Hi all,

It depends on what he really want, but pathinfo really is a better option

My test worked perfectly on files with no extension and without name...

var_dump( pathinfo( '.htaccess' ));
var_dump( pathinfo( 'htaccess' ));
die( );

On Fri, Oct 31, 2008 at 2:57 PM, Daniel P. Brown

On Fri, Oct 31, 2008 at 9:53 AM, Kyle Terry <kyle@xxxxxxxxxxxxx> wrote:
Thanks for the reply. For now I used substr($filename,0,-4) and that
perfectly. I need to learn reg ex badly :(.

Before you do that, learn to read and follow along in an email
thread that you start. We gave you perfect pointers as to (a) why
regexp's aren't needed in this case; and (b) how to better handle it.

Your substr() routine won't work as expected in all cases.
Imagine either an .htaccess file or an extensionless file named
`quagmire`. You'll come up with `cess` and `mire`, respectively.

</Daniel P. Brown>
daniel.brown@xxxxxxxxxxxx || danbrown@xxxxxxx
Ask me about our current hosting/dedicated server deals!

PHP General Mailing List (
To unsubscribe, visit:


Diogo Neves
Web Developer @ by

Relevant Pages

  • Re: Making a PHP program look like a directory.
    ... I am experimenting with a PHP program I'm writing. ... > have the PHP pretend to be a directory. ... another route to explore is the Apache ... remaining portion being the PathInfo part (this PathInfo by the way, ...
  • Re[2]: [PHP] Reg Ex
    ... Extension is a part of it. ... var_dump(pathinfo('htaccess')); ... Sincerely Yours, ANR Daemon ...
  • Re: [PHP] Parsing URLs
    ... One could also abuse basename and pathinfo. ... Works in PHP4+ ...