I've done a fair bit of googling and couldn't find anything that works, I'm just getting nothing back, this is probably something simple but there's a lot of variations that don't seem to match what I'm doing.
To give you an overall idea what I'm at, I'm accessing an API and getting back info as an object. There are comments and attachments, these are in separate arrays.
What i want to do is display the comments and attachments all together in the order of the date and time not separately.
I figured the best way is to create a loop through the comments array, then create a loop through the attachment array, then join both and sort by the date (epoch) and then loop through the whole merged loop echoing what i want. That should provide some context, right now i just want to create the multidimensional array for comments and i can figure out the rest.
$comments_holder = array(); //total number of comments in the array $comment_total = $issue_json->fields->comment->total -1; $i=1; while ($i <= $comment_total) { //this is the date,time and timezone info for each comment $raw_date = $issue_json->fields->comment->comments[$i]->updated; $comments_holder[$i] = array(); //convert_sql_time just converts from 2012-11-04T16:33:00.936+600 into epoch time so i can sort the results later based on date $comments_holder[$i]['comments_date'] = convert_sql_time($raw_date); $comments_holder[$i]['comments_displayName'] = $issue_json->fields->comment->comments[$i]->author->displayName; $comments_holder[$i]['comments_body'] = $issue_json->fields->comment->comments[$i]->body; }
foreach
to iterate trough arrays. php.net/manual/en/control-structures.foreach.php