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!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to