我有这个字符串(来自 GoDaddy 列表 xml),我希望将每个值分配给一个变量:
拍卖类型:报价,拍卖结束时间:08/12/2012 05:57 AM (PDT),价格:4,000 美元,投标数量:0,域名年龄:0,描述:1234 我宣布拇指战争,1234ideclareathumbwar.com,流量:0,估值:0 美元,IsAdult:真
我的问题是,我该如何使用正则表达式?
我已经试过了:
$re = "Auction Type: (.+?), ";
$re .= "Auction End Time: (.+?) \(.+?\), ";
$re .= "Price: .(.+?), ";
$re .= "Number of Bids: (.+?), ";
$re .= "Domain Age: (.+?), ";
$re .= "Description: (.*?), ";
$re .= "Traffic: (\d*)(.*?)";
$re .= "Valuation: (.+?), ";
$re .= "IsAdult: (.+?), ";
if(preg_match("~".$re."~is",$description,$m)){
$record = Array('auctiontype' => trim($m[1]),
'endtime' => strtotime($m[2]),
'price' => str2float($m[3]),
'bids' => trim($m[4]),
'age' => trim($m[5]),
'description' => addslashes(trim($m[6])),
'traffic' => trim($m[7]),
'valuation' => trim($m[8]),
'isadult' => trim($m[9])
);
}
但它不起作用。我可以寻求帮助吗?
谢谢!