-2
我有腳本,從其他網站的廢料/取html表數據。網站日期格式是26/8/2011,我怎樣才能把它改成這種格式2011-12-13 ??轉換日期格式
function createRSSFile($tag,$value,$data)
{
# this will return the each element with tag.
$tag=strtolower(str_replace(" ","_",$tag));
$tag=strtolower(str_replace(":","",$tag));
$tag=strtolower(str_replace("&","and",$tag));
$returnITEM = "<".$tag.">".htmlspecialchars(str_replace(" 00:00:00","",$value))."</".$tag.">";
return $returnITEM;
}
function fetchData($jobid) {
$html=file_get_contents('http://acbar.org/JobDetail.aspx?id='.$jobid);
$html=str_replace("<td></td>", "",$html);
$html=str_replace("<td style=\"font-size:8pt;font-weight:bold;\"></td>","<td style=\"font-size:8pt;font-weight:bold;\">Null</td>",$html);
$html=str_replace("<td style=\"font-size:8pt;font-weight:bold;\" colspan=\"2\" ></td>","<td style=\"font-size:8pt;font-weight:bold;\" colspan=\"2\" >Null</td>",$html);
$html=str_replace(" ", " ",$html);
$html=str_replace("?", "<br>",$html);
$html=str_replace("<br>", "_br_",$html);
$dom = new DOMDocument;
$dom->loadHTML($html);
//echo $dom->saveHTML();
//exit;
$rows = array();
foreach($dom->getElementsByTagName('tr') as $tr) {
$cells = array();
foreach($tr->getElementsByTagName('td') as $td) {
if(trim($td->nodeValue)!='')
$cells[] = str_replace("_br_","<br>",trim($td->nodeValue));
}
if(sizeof($cells)>0)
$rows[] = $cells;
}
那不是僅僅是一個簡單的正則表達式? –