Reputation: 11
I read trought How to loop through objects in php But still don't get it to work
Has someone an idea? Here is my php
$Topic_OBJ = json_decode($this->api_local_get($url));
$Text_IDS = "";
foreach ($Topic_OBJ as $obj) {
$Text_IDS .= $obj->Text->Text_id.",";
}
$Topic_OBJ looks like
{
"TextContainer_id": 339131662,
"Text": [
{
"Text_id": 794887707,
"TextContainer_id": 339131662
},
{
"Text_id": 794887711,
"TextContainer_id": 339131662
}
]
}
But Text_IDS is only ",," but should be "794887707,794887711,"
Can someone help me please? thanks rob
Upvotes: 0
Views: 45
Reputation: 1523
You should loop over the $Topic_OBJ->Text
array instead like so...
<?php
$Topic_OBJ = json_decode($this->api_local_get($url));
$Text_IDS = "";
foreach ($Topic_OBJ->Text as $text) {
$Text_IDS .= $text->Text_id.",";
}
Upvotes: 1