Accessing fields in object

I am trying to access the fields in this array:

Array
(
[0] => SObject Object
(
[type] => OpportunityLineItem
[fields] => SimpleXMLElement Object
(
[PricebookEntryId] => 01u40000001DjKTAA0
)

[Id] => 00kT00000028dgcIAA
[sobjects] => Array
(
[0] => SObject Object
(
[type] => PricebookEntry
[fields] => SimpleXMLElement Object
(
[Name] => 5962-3812803MPA
)

)

)

)

This print_r comes from this code:


$records = get_records($client,$soql);
echo '<pre>' . print_r($records, true) . '</pre>';



The whole code snippet is this:


if ($records)
{
echo '<p>There are currently ' . count($records) . ' products:</p>';
echo '<pre>' . print_r($records, true) . '</pre>';
foreach ($records as $r)
{
$r = new SObject($r);
echo "<br />part number:".$records->sobject[0]->sobjects[0]->sobject->fields->Name;
}
}

I hope this make sense and would appreciate any insight that anyone may have

TIA,
MikeI believe you should be able to do something like:

echo $records[0]->fields->PricebookEntryId;
 
Back
Top