using php 5 to loop through an array of objects
Posted: Fri Jun 26, 2009 8:50 am
pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Hi I am currently re-writing a manage my account java application into PHP as we bought a new CMS called EZ Publish and moving all our sites into this. now one of the methods I am having a little difficulty with I will display the java code below and hopefully someone can point me in the right direction. The data is coming from a soap responce and then is stored in an array object and then encapsulted in a DTO
Ok so here is the java part of method I am currently having trouble with converting to PHP:
Now I would like to know how to write that for loop in php as what I have tried is giving me an error's each time.
I have tried this code and it is not working, is there something I am missing here, Please advise
the error I get is: Fatal error: Cannot use object of type customer_address as array
Thanks
Sean
pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Hi I am currently re-writing a manage my account java application into PHP as we bought a new CMS called EZ Publish and moving all our sites into this. now one of the methods I am having a little difficulty with I will display the java code below and hopefully someone can point me in the right direction. The data is coming from a soap responce and then is stored in an array object and then encapsulted in a DTO
Ok so here is the java part of method I am currently having trouble with converting to PHP:
Code: Select all
Address_info_select_responseCustomer_address customerAddresses[] = addressInfoSelectResponse.getCustomer_address();
Address_info_select_responseCustomer_address customerAddress = null;
OAGENetCustomerAddressTO enetCustomerAddressTO = null;
String state = null;
for (int i = 0; i < customerAddresses.length; i++)
{
customerAddress = customerAddresses[i];
enetCustomerAddressTO = new OAGENetCustomerAddressTO() enetCustomerAddressTO.setAddressSequence(customerAddress.getCustomer_address_seq());
if(customerAddress.getCompany() != null){
enetCustomerAddressTO.setCompany(customerAddress.getCompany());
}
if(customerAddress.getAddress1() != null){
enetCustomerAddressTO.setAddress1(customerAddress.getAddress1());
}Code: Select all
$address_info_select_response = new address_info_select_response();
$address_info_select_response = $ThinkSoap->AddressInfoSelect($address_info_select_request);
$customer_addresses = new customer_address();
$customer_addresses = array();
$customer_addresses = $address_info_select_response->customer_address;
$customer_address = new customer_address();
$customer_address = null;
for ($i = 0; $i < sizeof($customer_addresses); $i++){
$customer_address .= $customer_addresses[$i];
$eclipseAddress = new EclipseNetAddress();
$eclipseAddress->addressSequence = $customer_address->customer_address_seq;
if ($customer_address->company != null){
$eclipseAddress->company = $customer_address->company;
}
}the error I get is: Fatal error: Cannot use object of type customer_address as array
Thanks
Sean
pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: