
22.11.2008, 08:43
|
|
Участник форума
Регистрация: 26.12.2006
Сообщений: 107
Провел на форуме: 228267
Репутация:
27
|
|
Здравствуйте, такой вопрос: есть вот такой код:
PHP код:
$result = $db->sql_query("SELECT `time` FROM ".$prefix."_stories ORDER BY `time` DESC");
$content .="<ul>";
while(list($time) = $db->sql_fetchrow($result)) {
if ($i<=11) {
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $time, $getdate);
if ($getdate[2] == "01") { $month = _JANUARY; } elseif ($getdate[2] == "02") { $month = _FEBRUARY; } elseif ($getdate[2] == "03") { $month = _MARCH; } elseif ($getdate[2] == "04") { $month = _APRIL; } elseif ($getdate[2] == "05") { $month = _MAY; } elseif ($getdate[2] == "06") { $month = _JUNE; } elseif ($getdate[2] == "07") { $month = _JULY; } elseif ($getdate[2] == "08") { $month = _AUGUST; } elseif ($getdate[2] == "09") { $month = _SEPTEMBER; } elseif ($getdate[2] == "10") { $month = _OCTOBER; } elseif ($getdate[2] == "11") { $month = _NOVEMBER; } elseif ($getdate[2] == "12") { $month = _DECEMBER; }
if ($month != $thismonth) {
$year = $getdate[1];
$content .= "<li><a href=\"index.php?name=News_Archive&sa=show_month&year=$year&month=$getdate[2]&month_l=$month\">$month, $year</a></li>\n";
$thismonth = $month;
$i++;
}
}
}
А теперь вопрос:
Можно ли ускорить выполнение этого скрипта заменой регулярки на другую (допустим preg_match):
Код:
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $time, $getdate);
или можно ли вообще как-нибудь обойтись без регулярного выражения?
|
|
|