Reputation: 19
I have a Souap Request and I do not know how I can go through all VoucherCodeItems with foreach. I tried this, but it dosn't work:
foreach($response->VoucherCodeCollection->VoucherCodeItem AS $key => $val) {
echo "Feld $key hat den Wert: $val<br>";
}
This is what i get when make a print like:
print_r($response);
Result
stdClass Object
(
[TotalResults] => 2
[VoucherCodeCollection] => stdClass Object
(
[VoucherCodeItem] => Array
(
[0] => stdClass Object
(
[Id] => 215523
[ProgramId] => 6767
[Code] =>
[Title] => Adventskalender
[Description] => Im Adventskalender
)
[1] => stdClass Object
(
[Id] => 215453
[ProgramId] => 8476
[Code] =>
[Title] => Wir schenken dir 15 EUR!!
[Description] =>
)
)
)
)
Upvotes: 0
Views: 332
Reputation: 46602
You can't directly echo out the object:
Try:
foreach ($response->VoucherCodeCollection->VoucherCodeItem as $key => $val) {
echo "Feld $key hat den Wert: {$val->Title}<br>";
}
Upvotes: 1