我有以下代碼... $mainResponse = array( "result" => array( ), "ack" => "success" ); foreach($resp->searchResult->item as $item) { $itemId = $item->itemId; $addThisItem = array("itemId" => $itemId); array_push($mainResponse['result'], $addThisItem); }} echo json_encode($mainResponse);輸出:{"result":[{"itemId":{"0":"183851233368"}}],"ack":"success"}預期產出:{"result":[{"itemId":"183851233368"},...],"ack":"success"}編輯:響應作為 XML 接收。我用$resp = simplexml_load_file($apicall);$resp->searchResult->item這是一個項目列表。像......[{"itemId":"1"},{"itemId":"2"}...]包含我需要的一切。如果我打印$itemId,我會得到我的 itemId。$分別...<findCompletedItemsResponse xmlns=""><ack>Success</ack><version>1.13.0</version><timestamp>2019-06-18T18:23:20.844Z</timestamp><searchResult count="1"><item><itemId>183851233368</itemId><title>2019 Bowman Mega Box SEALED LOT 4 Wander Franco Vlad Joey Bart TARGET Exclusive!</title><globalId>EBAY-US</globalId><primaryCategory><categoryId>213</categoryId><categoryName>Baseball Cards</categoryName></primaryCategory><galleryURL>http://thumbs1.ebaystatic.com/m/msMvr_Xz-51zlz4it4tOOLw/140.jpg</galleryURL><viewItemURL>http://www.ebay.com/itm/2019-Bowman-Mega-Box-SEALED-LOT-4-Wander-Franco-Vlad-Joey-Bart-TARGET-Exclusive-/183851233368</viewItemURL><paymentMethod>PayPal</paymentMethod><autoPay>false</autoPay><postalCode>60098</postalCode><location>Woodstock,IL,USA</location><country>US</country><shippingInfo><shippingServiceCost currencyId="USD">4.99</shippingServiceCost><shippingType>Flat</shippingType><shipToLocations>Worldwide</shipToLocations><expeditedShipping>true</expeditedShipping>我究竟做錯了什么?
- 1 回答
- 0 關注
- 368 瀏覽
添加回答
舉報
0/150
提交
取消