目前,我有下面的代碼,但由於某種原因,它只能輸出一個項目的foreach沒有表現出一個以上的變量
基本上我試圖做的是說的foreach mainPropertyUrl
創建的列表的foreach上市,但由於某種原因我只找回一個ListingId
主要飼料所在地 - http://api.trademe.co.nz/v1/Member/4389666/Listings/All.xml
PHP:
$mainXmlUrl = simplexml_load_file("http://api.trademe.co.nz/v1/Member/4389666/Listings/All.xml");
$listing = $mainXmlUrl->List->Listing;
$mainPropertyUrl = simplexml_load_file("http://api.trademe.co.nz/v1/Listings/$listing->ListingId.xml");
在我的HTML我試圖做一個普通foreach循環,但不使用$url
變量作爲我不確定我會如何與一個上市工作的代碼來實現它。
我也試圖打造上市ID數組,但它不顯示數據:
$ListingArray = array();
foreach ($listing[0] as $id) {
$IDNum = $id->ListingId;
$ListingArray[] = $IDNum;
}
var_dump($ListingArray);
HTML SNIPPIT:
<?php foreach ($mainPropertyUrl as $url): ?>
<div class="listingContainer">
<h2><?php echo $tradeMePropertyAddressFull;?></h2>
<div class="listingAttributes">
<div class="col0">
<span class="name"><?php echo $mainPropertyDetails[0]->Attribute[0]->DisplayName;?>:</span>
<span class="value"><?php echo $tradeMePropertyBathrooms[0];?></span>
http://pinterest.com/pin/343118065329946155/ – markus