compubasic Posted August 21, 2020 Share Posted August 21, 2020 I'm using a PHP framework someone built that allows for easier use of the Autotask ticketing/CRM system API. I have been able to navigate querying the database, but cannot seem to read through the data it returns. A var_dump of the results shows the following: object(ATWS\AutotaskObjects\QueryResponse)[9] public 'queryResult' => object(ATWS\AutotaskObjects\ATWSResponse)[10] public 'EntityResults' => object(ATWS\AutotaskObjects\ArrayOfEntity)[11] public 'Entity' => array (size=500) ... public 'EntityResultType' => string 'contact' (length=7) public 'EntityReturnInfoResults' => object(ATWS\AutotaskObjects\ArrayOfEntityReturnInfo)[1028] public 'EntityReturnInfo' => array (size=500) ... public 'Fields' => null public 'UserDefinedFields' => null public 'Errors' => object(ATWS\AutotaskObjects\ArrayOfATWSError)[1027] public 'ATWSError' => null public 'Fields' => null public 'UserDefinedFields' => null public 'ReturnCode' => int 1 Can someone please give me guidance on how I can get to the data in this result. I'm trying to get my hands on the "EntityReturnInfo" data. A sample is as follows Here is what a print_r returns ATWS\AutotaskObjects\QueryResponse Object ( [queryResult] => ATWS\AutotaskObjects\ATWSResponse Object ( [EntityResults] => ATWS\AutotaskObjects\ArrayOfEntity Object ( **THIS IS WHERE THE GOOD DATA STARTS*** [Entity] => Array ( [0] => ATWS\AutotaskObjects\Contact Object ( [AccountID] => 174 [Active] => 1 [FirstName] => John [LastName] => Doe [AccountPhysicalLocationID] => [AdditionalAddressInformation] => [AddressLine] => 123 Fake Street [AddressLine1] => Suite 2 [AlternatePhone] => [BulkEmailOptOut] => [BulkEmailOptOutTime] => [City] => Fake City [Country] => United States [CountryID] => 237 [CreateDate] => 2016-09-28T10:17:57.34 [EMailAddress] => Fake@email.com [EMailAddress2] => [EMailAddress3] => [Extension] => [ExternalID] => [FacebookUrl] => [FaxNumber] => [LastActivityDate] => 2016-09-28T11:17:24 [LastModifiedDate] => 2016-09-28T11:17:24.68 [LinkedInUrl] => [MiddleInitial] => [MobilePhone] => [NamePrefix] => [NameSuffix] => [Note] => [Notification] => 1 [Phone] => 123-456-7890 [PrimaryContact] => [RoomNumber] => [SolicitationOptOut] => [SolicitationOptOutTime] => [State] => NY [SurveyOptOut] => [Title] => [TwitterUrl] => [ZipCode] => 12345 [Fields] => [UserDefinedFields] => ATWS\AutotaskObjects\ArrayOfUserDefinedField Object ( [UserDefinedField] => ) [id] => 30682885 ) ***AND THE DATA CONTINUES WITH*** [1] => ATWS\AutotaskObjects\Contact Object ( [AccountID] => etc etc etc etc Quote Link to comment https://forums.phpfreaks.com/topic/311364-reading-a-multi-dimensional-array/ Share on other sites More sharing options...
requinix Posted August 21, 2020 Share Posted August 21, 2020 object(ATWS\AutotaskObjects\QueryResponse)[9] public 'queryResult' => object(ATWS\AutotaskObjects\ATWSResponse)[10] public 'EntityReturnInfoResults' => object(ATWS\AutotaskObjects\ArrayOfEntityReturnInfo)[1028] public 'EntityReturnInfo' => array (size=500) ... 1. Whatever you dumped was a QueryResponse object. 2. It has a property named "queryResult" which is a ATWSResponse. 3. It has a property named "EntityReturnInfoResults" which is an ArrayOfEntityReturnInfo object. 4. It has a property named "EntityReturnInfo" which is an array of something. Quote Link to comment https://forums.phpfreaks.com/topic/311364-reading-a-multi-dimensional-array/#findComment-1580840 Share on other sites More sharing options...
compubasic Posted August 21, 2020 Author Share Posted August 21, 2020 Thank you @requinix! Obviously There's some basics I need to learn here regarding working with this... How to I reference the data in my variable all the way down at the EntityReturnInfo array? Quote Link to comment https://forums.phpfreaks.com/topic/311364-reading-a-multi-dimensional-array/#findComment-1580842 Share on other sites More sharing options...
requinix Posted August 21, 2020 Share Posted August 21, 2020 Are you familiar with objects? Seen the -> operator? Quote Link to comment https://forums.phpfreaks.com/topic/311364-reading-a-multi-dimensional-array/#findComment-1580844 Share on other sites More sharing options...
compubasic Posted August 21, 2020 Author Share Posted August 21, 2020 Familiar yes, really know how to use it, no. If you can point me to an overview I'd love to get my knowledge where it needs to be. Quote Link to comment https://forums.phpfreaks.com/topic/311364-reading-a-multi-dimensional-array/#findComment-1580846 Share on other sites More sharing options...
requinix Posted August 21, 2020 Share Posted August 21, 2020 It's really quite simple. Object goes on the left, name of the thing you want goes on the right. https://www.php.net/manual/en/language.oop5.properties.php Quote Link to comment https://forums.phpfreaks.com/topic/311364-reading-a-multi-dimensional-array/#findComment-1580848 Share on other sites More sharing options...
compubasic Posted August 21, 2020 Author Share Posted August 21, 2020 Wow that is simple. Thank you @requinix. If only I asked for help sooner... Quote Link to comment https://forums.phpfreaks.com/topic/311364-reading-a-multi-dimensional-array/#findComment-1580851 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.