21,893
社区成员




preg_match("/<yw:cdtn.*?\/>/",$content,$matches);
preg_match_all("/(text|code|temp|date)=\"([^\"]+)\"/",$matches[0],$matches,PREG_SET_ORDER);
foreach($matches as $value) $cdtn[$value[1]]=$value[2];
preg_match_all("/<yw:f.*?\/>/",$content,$matches);
foreach($matches[0] as $key=>$value){
preg_match_all("/(day|date|low|high|text|code)=\"([^\"]+)\"/",$value,$matches_,PREG_SET_ORDER);
foreach($matches_ as $value_) $f[$key][$value_[1]]=$value_[2];
}
var_dump($cdtn);
var_dump($f);
array(4) {//$cdtn
["text"]=>
string(4) "Fair"
["code"]=>
string(2) "34"
["temp"]=>
string(1) "7"
["date"]=>
string(28) "Thu, 10 Apr 2008 9:50 am BST"
}
array(2) {//$f
[0]=>
array(6) {
["day"]=>
string(3) "Thu"
["date"]=>
string(11) "10 Apr 2008"
["low"]=>
string(1) "1"
["high"]=>
string(2) "11"
["text"]=>
string(10) "Light Rain"
["code"]=>
string(2) "11"
}
[1]=>
array(6) {
["day"]=>
string(3) "Fri"
["date"]=>
string(11) "11 Apr 2008"
["low"]=>
string(1) "1"
["high"]=>
string(2) "10"
["text"]=>
string(10) "Light Rain"
["code"]=>
string(2) "11"
}
}