Jump to content

[SOLVED] Help Parsing This Array


RIRedinPA

Recommended Posts

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

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... >:(

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!

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.