Kris1511
Kris1511

Reputation: 300

Listing Array Issue

I am calling a webservice and I am getting a complex object back. I need to display variables reg_no, opening_inventory_weight.

RESULT:-
object(stdClass)#12 (3) { 
    ["TxnErrors"]=>  object(stdClass)#13 (0) { } 
    ["TxnStatus"]=>  bool(true) 
    ["headers"]=>  object(stdClass)#14 (1) { 
        ["RPMHeader"]=>  array(1) { 
            [0]=>  object(stdClass)#15 (7) { 
                ["opening_inventory_weight"]=>  int(1001) 
                ["prepared_by"]=>  string(5) "James" 
                ["reg_no"]=>  string(7) "5000005" 
                ["reporting_period"]=>  string(19) "2010-02-01T00:00:00" 
                ["rsid"]=>  int(49) ["status"]=>  string(1) "D" 
                ["web_user_id"]=>  string(1) "0" } } } }

I am calling it like


 $result = call_search_existing_manufacturer();
 $rows = array();
 foreach ($result->RPMHeader as $data)
    { 
   $rows[] = array( 
      $data->reg_no, 
      $data->opening_inventory_weight,
      $data->status
     );
     }

But its not working. Any Idea what am I missing? Thank you in advance

Upvotes: 0

Views: 82

Answers (2)

Sinan
Sinan

Reputation: 5980

I think it should be

 $result = call_search_existing_manufacturer();
 $rows = array();
 foreach ($result->headers->RPMHeader as $data)
    { 
   $rows[] = array( 
      $data->reg_no, 
      $data->opening_inventory_weight,
      $data->status
     );
}

Upvotes: 1

skyman
skyman

Reputation: 2472

Your result dump isn't esay too read, so I may be wrong, but it looks like RPMHeader is part of headers field, so you should access it like

$result->headers->RPMHeader

Upvotes: 1

Related Questions