function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
chuckdubdubchuckdubdub 

Parsing sObject array data (from NuSOAP!)

I have a client whose hosting provider won't install the SOAP module for their PHP install, so bear with me.

 

Essentially I'm trying to loop through the output below and create standards variables for field names and their values.  I keep getting stumped because of the sObject reference.  I've tried flattening the array, but anytime I try and loop through it like a regular array or even a nest array, I'm hit by the fact that I can't address sObject in the same way.  What basic thing am I missing, some method of addressing the sObject -> addresses, but I'm just not getting it.

 

Any suggestions, much appreciated.

 

Thanks!

 

Chuck

 

 

Array ( [done] => true [queryLocator] => [records] => Array ( [0] => sObject Object ( [type] => Lead [id] => 00Q7000000WDBamEAH [values] => Array ( [FirstName] => Chuck YET another test record to leave [LastName] => Wyatt please leave for nurture testing [Email] => nurturetestagain@wordimpressive.com [VFS_Trial_Begins__c] => 2010-08-10 ) [fieldsToNull] => ) [1] => sObject Object ( [type] => Lead [id] => 00Q7000000WDBaXEAX [values] => Array ( [FirstName] => Chuck another test record to leave [LastName] => Wyatt leave for nurture testing [Email] => nurturetest@wordimpressive.com [VFS_Trial_Begins__c] => 2010-08-10 ) [fieldsToNull] => ) [2] => sObject Object ( [type] => Lead [id] => 00Q7000000WDBPLEA5 [values] => Array ( [FirstName] => Chuck more placement for nurture testing [LastName] => Wyatt leave this record for a bit [Email] => pleaseleave@wordimpressive.com [VFS_Trial_Begins__c] => 2010-08-10 ) [fieldsToNull] => ) ) [size] => 3 )

 

chuckdubdubchuckdubdub

Found this... btw.... functions like this are your friend:

 

// need this function to break up SF object into an array
  // objt to array function
function obj2array($obj) {
 $out = array();
 foreach ($obj as $key => $val) {
   switch(true) {
    case is_object($val):
        $out[$key] = obj2array($val);
        break;
     case is_array($val):
        $out[$key] = obj2array($val);
        break;
     default:
       $out[$key] = $val;
   }
 }
 return $out;
}