RIRedinPA Posted May 26, 2009 Share Posted May 26, 2009 I can't seem to figure out how to parse the data from this array (which is being returned from a SOAP call) The array is stored in this variable: print_r($RetrieveContactResults['RetrieveResult']); Which prints out as: Array ( [CvObject] => Array ( [CustomFieldDetail] => Array ( [0] => Array ( [!FieldName] => Department / Division [!FieldType] => Open Ended Text - One Line [!FieldValue] => [!FieldId] => 3E8FB55D-XXXX-XXXX-9E5A-56785E1C949A ) [1] => Array ( [!FieldName] => Website [!FieldType] => Open Ended Text - One Line [!FieldValue] => [!FieldId] => BF5557E3-5A53-XXXX-XXXX-F31092AD0B1C ) [2] => Array ( [!FieldName] => Password [!FieldType] => Open Ended Text - One Line [!FieldValue] => [!FieldId] => 60BF3480-XXXX-XXXX-B4AA-C0D577CBB1EC ) [3] => Array ( [!FieldName] => Membership [!FieldType] => Choice - Single Answer (Horizontal) [!FieldValue] => [!FieldId] => B8D6ED73-5BD9-XXXX-XXXX-7C271DF7C943 ) ) [!Id] => C5BFF79F-XXXX-XXXX-82BE-A0D454AAE3E6 [!SourceId] => [!FirstName] => Emily [!LastName] => Stinger [!EmailAddress] => [email protected] [!CCEmailAddress] => [!Company] => [!Title] => [!ContactType] => [!ContactTypeCode] => [!Salutation] => [!Nickname] => [!MiddleName] => [!Designation] => [!ExcludedFromEmail] => false [!CreatedDate] => 2009-03-30T18:41:00 [!CreatedBy] => NAXXXXX001Api [!LastModifiedDate] => 2009-03-30T18:41:00 [!LastModifiedBy] => NAXXXXX001Api [!EmailAddressStatus] => No Email Sent [!LogReason] => [!LogResponse] => [!PrimaryAddressType] => Work [!HomeAddress1] => [!HomeAddress2] => [!HomeAddress3] => [!HomeCity] => [!HomeState] => [!HomeStateCode] => [!HomePostalCode] => [!HomeCountry] => [!HomeCountryCode] => [!HomePhone] => [!HomeFax] => [!WorkAddress1] => XX Greenwood XX [!WorkAddress2] => [!WorkAddress3] => [!WorkCity] => Collegeville [!WorkState] => [!WorkStateCode] => [!WorkPostalCode] => XXXXX [!WorkCountry] => [!WorkCountryCode] => [!WorkPhone] => XXX-XXX-XXXX [!WorkFax] => [!MobilePhone] => [!Pager] => ) ) I've tried variations of: print $RetrieveContactResults['RetrieveResult']['!FirstName'] with no luck. Thanks. Link to comment https://forums.phpfreaks.com/topic/159766-solved-help-parsing-this-array/ Share on other sites More sharing options...
thebadbad Posted May 26, 2009 Share Posted May 26, 2009 echo '<pre>', print_r($RetrieveContactResults['RetrieveResult'], true), '</pre>'; will give you a much better idea of how the arrays are nested (or you could just check the HTML source). Link to comment https://forums.phpfreaks.com/topic/159766-solved-help-parsing-this-array/#findComment-842661 Share on other sites More sharing options...
RIRedinPA Posted May 26, 2009 Author Share Posted May 26, 2009 I didn't know that, it helps but I am still not getting any results. This code: print '<pre>' . print_r($RetrieveContactResults['RetrieveResult'], true) . '</pre>'; gives me these results: Array ( [CvObject] => Array ( [CustomFieldDetail] => Array ( [0] => Array ( [!FieldName] => Department / Division [!FieldType] => Open Ended Text - One Line [!FieldValue] => [!FieldId] => 3E8FB55D-XXXX-XXXX-9E5A-56785E1C949A ) [1] => Array ( [!FieldName] => Website [!FieldType] => Open Ended Text - One Line [!FieldValue] => [!FieldId] => BF5557E3-XXXX-XXXX-9003-F31092AD0B1C ) [2] => Array ( [!FieldName] => Password [!FieldType] => Open Ended Text - One Line [!FieldValue] => [!FieldId] => 60BF3480-XXXX-XXXX-B4AA-C0D577CBB1EC ) [3] => Array ( [!FieldName] => Membership [!FieldType] => Choice - Single Answer (Horizontal) [!FieldValue] => [!FieldId] => B8D6ED73-XXXX-XXXX-BB1F-7C271DF7C943 ) ) [!Id] => C5BFF79F-49E2-4C63-82BE-A0D454AAE3E6 [!SourceId] => [!FirstName] => Emily [!LastName] => Stinger [!EmailAddress] => [email protected] [!CCEmailAddress] => [!Company] => [!Title] => [!ContactType] => [!ContactTypeCode] => [!Salutation] => [!Nickname] => [!MiddleName] => [!Designation] => [!ExcludedFromEmail] => false [!CreatedDate] => 2009-03-30T18:41:00 [!CreatedBy] => NXXXXXApi [!LastModifiedDate] => 2009-03-30T18:41:00 [!LastModifiedBy] => NXXXXXApi [!EmailAddressStatus] => No Email Sent [!LogReason] => [!LogResponse] => [!PrimaryAddressType] => Work [!HomeAddress1] => [!HomeAddress2] => [!HomeAddress3] => [!HomeCity] => [!HomeState] => [!HomeStateCode] => [!HomePostalCode] => [!HomeCountry] => [!HomeCountryCode] => [!HomePhone] => [!HomeFax] => [!WorkAddress1] => XX Greenwood XX [!WorkAddress2] => [!WorkAddress3] => [!WorkCity] => Collegeville [!WorkState] => [!WorkStateCode] => [!WorkPostalCode] => XXXXX [!WorkCountry] => [!WorkCountryCode] => [!WorkPhone] => XXX-XXX-XXXX [!WorkFax] => [!MobilePhone] => [!Pager] => ) ) I would think then that this would give me the first name (the object for this call is Contact): print "<br>" . $RetrieveContactResult['RetrieveResult']['Contact']['!FirstName']; but I am still not getting anything...grumble...grumble... Link to comment https://forums.phpfreaks.com/topic/159766-solved-help-parsing-this-array/#findComment-842675 Share on other sites More sharing options...
thebadbad Posted May 26, 2009 Share Posted May 26, 2009 echo $RetrieveContactResults['RetrieveResult']['CvObject']['!FirstName']; Hope you can see how I got that. Link to comment https://forums.phpfreaks.com/topic/159766-solved-help-parsing-this-array/#findComment-842699 Share on other sites More sharing options...
RIRedinPA Posted May 26, 2009 Author Share Posted May 26, 2009 echo $RetrieveContactResults['RetrieveResult']['CvObject']['!FirstName']; Hope you can see how I got that. OK, I was using print $RetrieveContactResults['RetrieveResult']['CvObject']['!FirstName']; Why did echo work and not print? Oh, and mucho grande thanks! Link to comment https://forums.phpfreaks.com/topic/159766-solved-help-parsing-this-array/#findComment-842705 Share on other sites More sharing options...
thebadbad Posted May 26, 2009 Share Posted May 26, 2009 print should work just as well. In your previous post you used 'Contact' instead of 'CvObject'. Link to comment https://forums.phpfreaks.com/topic/159766-solved-help-parsing-this-array/#findComment-842710 Share on other sites More sharing options...
RIRedinPA Posted May 26, 2009 Author Share Posted May 26, 2009 print should work just as well. In your previous post you used 'Contact' instead of 'CvObject'. I know, but I also used CvObject and it didn't work, I must have been typing it in wrong, maybe I used all caps instead of upper and lower case. Anyway thanks for the help. Link to comment https://forums.phpfreaks.com/topic/159766-solved-help-parsing-this-array/#findComment-842778 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.