【发布时间】:2016-08-15 07:42:39
【问题描述】:
我是正则表达式的新手,但我现在没有时间学习它, 但我需要将 eregi("^..?$", $file) 转换为 preg_match() 但我 不知道怎么弄,谁能帮帮我?
也让我对它的工作原理有所了解 很高兴拥有:)
这段代码:
$fileCount = 0;
while ($file = readdir($dh) and $fileCount < 5){
if (eregi("^..?$", $file)) {
continue;
}
$open = "./xml/".$file;
$xml = domxml_open_file($open);
//we need to pull out all the things from this file that we will need to
//build our links
$root = $xml->root();
$stat_array = $root->get_elements_by_tagname("status");
$status = extractText($stat_array);
$ab_array = $root->get_elements_by_tagname("abstract");
$abstract = extractText($ab_array);
$h_array = $root->get_elements_by_tagname("headline");
$headline = extractText($h_array);
if ($status != "live"){
continue;
}
echo "<tr valign=top><td>";
echo "<a href=\"showArticle.php?file=".$file . "\">".$headline . "</a><br>";
echo $abstract;
echo "</td></tr>";
$fileCount++;
}
【问题讨论】:
-
你可能得抓紧时间了,也许我们没有空余时间
-
快速浏览 Stack 会发现其他提出相同问题的人,也许这可能会有所帮助 stackoverflow.com/questions/2501494/…
-
与其等着别人为你写代码,不如开始学习正则表达式。这很简单。