0

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 )

0

2 Answers 2

1

you can do by this:

foreach($invoiceitems  as $row){
    echo $row['id'];
    echo $row['type'];
    .
    .
    .
    .
}
Sign up to request clarification or add additional context in comments.

Comments

1

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']

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.