我在PHP中解析數組時遇到了挑戰。這裏是陣列的輸出:用解碼解析PHP數組
[{"address":"2801 Elliott Ave","category_ids":[347],"category_labels":[["Social","Food and
Dining","Restaurants"]],"country":"us","email":"[email protected]","factual_id":"43cfe23
8-ae8e-469a-8592-a1edc8603051","fax":"(206) 448-
9252","latitude":47.615154,"locality":"Seattle","longitude":-122.353724,"name":"The Old
Spaghetti Factory","neighborhood":["Belltown","Downtown","Downtown
Seattle"],"postcode":"98121","region":"WA","tel":"(206) 441-
7724","website":"http:\/\/www.osf.com"}]
這裏是解析嘗試...
$mark = array("[");
$mark2 = array("]");
$replacemark = array("");
$array = str_replace($mark, $replacemark, $array);
$array = str_replace($mark2, $replacemark, $array);
$array = stripslashes($array);
$obj = json_decode($array);
$address = $obj->{'address'};
$country = $obj->{'country'};
$factual_id = $obj->{'factual_id'};
$latitude = $obj->{'latitude'};
$locality = $obj->{'locality'};
$longitude = $obj->{'longitude'};
$name = $obj->{'name'};
$postcode = $obj->{'postcode'};
$region = $obj->{'region'};
$status = $obj->{'status'};
$tel = $obj->{'tel'};
任何想法,爲什麼這些值不返回任何東西?謝謝!
什麼是所有替代atop應該完成? – mario