Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I have an object $invoiceitems - its a (smarty) object of array of arrays. I cannot work out how to access values within it.

For example how would I access 'relid' element in the second array?

//print_r($invoiceitems);

Smarty_Variable Object ( [value] => Array ( [0] => Array ( [id] => 40442 [type] => Hosting [relid] => 2913 [description] => TESTING [rawamount] => 24.00 [amount] => €24.00 EUR [taxed] => 1 ) [1] => Array ( [id] => 40443 [type] => Hosting [relid] => 2913 [description] => TESTING [rawamount] => 24.00 [amount] => €24.00 EUR [taxed] => 1 ) ) [nocache] => [scope] => 0 )

share|improve this question

Looks like the arrays are held within the value property of the object. So, to get the outer array, you'd use:

$invoiceitems->value

Then, to get relid from the second array:

$invoiceitems->value[1]['relid']

share|improve this answer

you can do by this:

foreach($invoiceitems  as $row){
    echo $row['id'];
    echo $row['type'];
    .
    .
    .
    .
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.