I have this string (comes from the GoDaddy listing xml) and I wish to assign each of the values to a variable:
Auction Type: Offer, Auction End Time: 08/12/2012 05:57 AM (PDT), Price: $4,000, Number of Bids: 0, Domain Age: 0, Description: 1234 I declare a thumb war, 1234ideclareathumbwar.com, Traffic: 0, Valuation: $0, IsAdult: true
My question is, how do I do so using regexp?
I've tried this out:
$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])
);
}
but it does not work. May I ask for assistance?
Thank you!