Forum Moderators: coopster
Here is a sample of one of the lines in the array (Using JSON)
[10]=> object(stdClass)#15 (2) { ["Name"]=> string(8) "Warranty" ["Value"]=> array(1) { [0]=> string(42) "Vehicle does NOT have an existing warranty" } }
About that array: Value is easy to deal with because [0] always returns the Value's value. Name on the other hand is frustrating me. In this example [10] is the array object for Warranty however on a different auction [10] may mean Mileage or Body type so I can't specify a number in the array and always get the same value.
Best effort, this works to display a list of all names and values in the array
foreach($resp->Item->ItemSpecifics->NameValueList as $itemspec) {
$specific_name = $itemspec->Name;
$specific_value = $itemspec->Value[0];
$results .= "$specific_name: $specific_value<br />";
}
I can grab the specific name I want like this
if ($specific_name='Mileage') {
echo WHAT GOES HERE TO GRAB SPECIFIC MILEAGE VALUE;}
and as you can see I'm just not seeing how to extract the value for a specific name. It seems simple but remember that you cannot use the [10] because it does not stay constant across all auctions and you cannot use Name because every line in the array uses it.
Any ideas?
foreach($array AS $part)
{
if($part['name'] == $specific_name)
return $part['value'];
}
/* if we can't find it return null */
return NULL;
See what you can do.
Using
foreach($resp->Item->ItemSpecifics->NameValueList as $itemspec) {
$specific_name = $itemspec->Name;
$specific_value = $itemspec->Value[0];
if ($specific_name == "Mileage")
$results .= "$specific_name: $specific_value<br />";
}