0

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

1 Answer 1

1

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.","; } 
Sign up to request clarification or add additional context in comments.

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.