melsom Posted January 5, 2011 Share Posted January 5, 2011 Hello, I'm trying to extract information about a ticket through osTicket SOAP API, but I can't seem to figure out how! This is the return from the script (var_dump): array(1) { [0]=> object(stdClass)#2 (2) { ["question"]=> object(stdClass)#3 (4) { ["id"]=> int(25) ["created"]=> string(25) "2011-01-05T01:19:43+01:00" ["name"]=> string(4) "test" ["message"]=> string(4) "qasd" } ["answers"]=> array(1) { [0]=> object(stdClass)#4 (4) { ["id"]=> int(25) ["created"]=> string(25) "2011-01-05T01:25:06+01:00" ["name"]=> string(17) "Andreas Haakonsen" ["message"]=> string(3) "ler" } } } } A ticket can have several answers. I just can't seem to figure out how to extract/use this data and present it on my webpage. Too many arrays for me to understand I guess Is there anyone who can help me with some small code to help me figure this one out? Thanks! Link to comment https://forums.phpfreaks.com/topic/223464-need-some-help-with-arrays/ Share on other sites More sharing options...
AbraCadaver Posted January 5, 2011 Share Posted January 5, 2011 Something like this should work: $question = $array[0]->question; echo $question->name; echo $question->message; $answers = $array[0]->answers; foreach($answers as $answer) { echo $answer->name; echo $answer->message; } Link to comment https://forums.phpfreaks.com/topic/223464-need-some-help-with-arrays/#findComment-1155263 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.