grabbing file number from article042.html?
| From: | Andrew Rowe | Date: | Fri, 11 May 2001 07:29:07 +0000 |
| Subject: | grabbing file number from article042.html? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-52414@lists.php.net to get a copy of this message | ||
I'm trying to get the number of a file where the filename=
article00x.html.
The dir looks like: 2001/article001.html, article002.html...
Currently I'm grabbing it using the following code:
$path_info = preg_split("/\//i", $PHP_SELF,-1, PREG_SPLIT_NO_EMPTY);
$current_file = end($path_info);
$current_year = prev($path_info); // gives me the year.
// is it a valid article name?
if (preg_match('/^' . ARTICLE_BASE_NAME . '\d{3}\.html$/i',
$current_file) )
{
*** $result = preg_split("/^" . ARTICLE_BASE_NAME . "/i",
$current_file,-1, PREG_SPLIT_NO_EMPTY);
*** $result = preg_split("/.html/i", end($result),-1,
PREG_SPLIT_NO_EMPTY);
^
| $filenumber = (int)reset($result);
|
Is this the best way to do it?
I have had no experience with Reg ex before this so fire away!