note 58481 deleted from function.preg-match by colder
| From: | colder@php.net | Date: | Mon, 18 Jun 2007 18:27:35 +0000 |
| Subject: | note 58481 deleted from function.preg-match by colder | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-127614@lists.php.net to get a copy of this message | ||
Note Submitter: rebootconcepts.com
----
Guarantee (one) trailing slash in $dir:
<?php
$dir = preg_match( '|(.*)/*$|U', $dir, $matches );
$dir = $matches[1] . '/';
?>
For whatever reason,
<?php $dir = preg_replace( '|^([^/]*)/*$|', '$1/', $dir ); ?>
and
<?php $dir = preg_replace( '|/*$|U', '/', $dir ); ?>
don't work (perfectly). The match, concat combo is the only thing I could get to work if there
was a '/' within $dir (like $dir = "foo/bar";