Currently I have the following code but for some reason it is only outputting one item
Basically What I have tried to do is say foreach mainPropertyUrl create a listing foreach listing but for some reason I am only getting back one ListingId
The main feed is located – 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");
In my HTML I have tried to do a general foreach loop but not using the $url variable as I am unsure how I would implement it with the code that worked for one listing.
I have also tried to create an array of the listing ids but its not showing the data:
$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>
Try:
You need to put
{}around object access syntax.UPDATE:
$listingis an array, so your loop should be: