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 )
you can do by this:
foreach($invoiceitems as $row){
echo $row['id'];
echo $row['type'];
.
.
.
.
}
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']
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.