Jump to content

Array Help


inspireddesign

Recommended Posts

Hello All!!

 

I have the following array:  How would I extract the values in the this array using a foreach loop?  Thanks!!

 

QuickBooks_Object_Customer Object ( [_object:protected] => Array ( [ListID] => 284 [TimeCreated] => 2010-11-23T13:09:22 [TimeModified] => 2010-11-26T10:07:47 [EditSequence] => 2 [Name] => Keith Palmer (1417262473) [FullName] => Keith Palmer (1417262473) [sublevel] => 0 [CompanyName] => New Company Name [FirstName] => Damian [LastName] => Clem [shipAddress Addr1] => 134 Stonemill Road [shipAddress City] => Storrs [shipAddress State] => CT [shipAddress PostalCode] => 06268 [PrintAs] => Keith Palmer (1417262473) [balance] => 0.00 [TotalBalance] => 0.00 [isStatementWithParent] => false [DeliveryMethod] => Print ) )

 

Link to comment
https://forums.phpfreaks.com/topic/219932-array-help/
Share on other sites

The array from print_r($Customer);

 

QuickBooks_Object_Customer Object ( [_object:protected] => Array ( [ListID] => 284 [TimeCreated] => 2010-11-23T13:09:22 [TimeModified] => 2010-11-26T10:07:47 [EditSequence] => 2 [Name] => Keith Palmer (1417262473) [FullName] => Keith Palmer (1417262473) [sublevel] => 0 [CompanyName] => New Company Name [FirstName] => Damian [LastName] => Clem [shipAddress Addr1] => 134 Stonemill Road [shipAddress City] => Storrs [shipAddress State] => CT [shipAddress PostalCode] => 06268 [PrintAs] => Keith Palmer (1417262473) [balance] => 0.00 [TotalBalance] => 0.00 [isStatementWithParent] => false [DeliveryMethod] => Print ) )

 

Here is what I have so far but there's no output.  Doesn't throw any errors.  Thanks for any help you can provide me.

 


$Customer = $API->getCustomerByName('Keith Palmer (1417262473)'); // Generates the Array I want to loop through.

foreach ( $Customer as $cust => $value ) {
	echo $cust['ListID'][$value];		
}	

 

Link to comment
https://forums.phpfreaks.com/topic/219932-array-help/#findComment-1140069
Share on other sites

An array? You think it's an array? Look at the output from print_r.

QuickBooks_Object_Customer Object (

What do you see in there that indicates it's an array?

 

 

You cannot access the information by normal means, according to that output. Since being totally inaccessible would be stupid, there's likely another way. Try

echo $Customer->ListID;

Link to comment
https://forums.phpfreaks.com/topic/219932-array-help/#findComment-1140077
Share on other sites

An array? You think it's an array? Look at the output from print_r.

QuickBooks_Object_Customer Object (

What do you see in there that indicates it's an array?

 

 

You cannot access the information by normal means, according to that output. Since being totally inaccessible would be stupid, there's likely another way. Try

echo $Customer->ListID;

 

you can still access them from a foreach loop.

Link to comment
https://forums.phpfreaks.com/topic/219932-array-help/#findComment-1140081
Share on other sites

Thanks for the help so far everyone.  Here's what I have right now as my output.  This is NOT protected by any class.  How would I extract this information using a foreach loop?  This is what I'm doing now and I'm only getting the first character in the loop.  Moreover, It's looping though the entire array printing everything and not what I've indicated in the loop.  Not sure why?  Thanks for any help on this!

 

Array ( [ListID] => 284 [TimeCreated] => 2010-11-23T13:09:22 [TimeModified] => 2010-11-26T10:07:47 [EditSequence] => 2 [Name] => Keith Palmer (1417262473) [FullName] => Keith Palmer (1417262473) [sublevel] => 0 [CompanyName] => New Company Name [FirstName] => Damian [LastName] => Clem [shipAddress Addr1] => 134 Stonemill Road [shipAddress City] => Storrs [shipAddress State] => CT [shipAddress PostalCode] => 06268 [PrintAs] => Keith Palmer (1417262473) [balance] => 1.00 [TotalBalance] => 1.00 [isStatementWithParent] => false [DeliveryMethod] => Print )

 


$custInfo = $API->getCustomerByName('Keith Palmer (1417262473)');
$custInfoArry = $custInfo->asList(QUICKBOOKS_ADD_CUSTOMER);

foreach ( $custInfoArry as $Customer ) {
	echo 'ListID: ' . $Customer['ListID'] . '<br />';		
}

Link to comment
https://forums.phpfreaks.com/topic/219932-array-help/#findComment-1140463
Share on other sites

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.