<?php
$theresults = array (
[0] => stdClass Object (
[id] => 1
[fruit] => Apple
[price] => 10
[total] => 7
)
[1] => stdClass Object (
[id] => 2
[fruit] => Orange
[price] => 15
[total] => 23
)
)
foreach ($theresults as $fruit => $values) {
foreach ($values as $value) {
echo $value;
}
}
?>
Output = 1Apple1072Orange1523
Nu komt alles achter elkaar maar wil deze array uitlezen als
<?php
echo $value[fruit].' - '.$value[price].' - '.$value[total];
?>
Maar krijg een error 'Use of undefined constant fruit'.