, 여기에 메신저가 시도 것입니다 하나는 주석을위한 것이고 다른 하나는 첨부 파일을위한 것입니다. 둘 다 API에서 당길 때 다른 객체이지만 조합 된 결과를 표시하고 결과를 출력하여 시간 순서대로 표시하려고합니다. 지금 예를 들어두 다차원 배열, 날짜 PHP에 의해 순서대로 에코 결합해야
의 :
comment 1 - 5th April
Comment 2 - 20th April
comment 3 - 9th June
attachment 1 - 5th April
attachment 2 - 20th April
I want to dislay that as:
comment 1 - 5th April
attachment 1 - 5th April
Comment 2 - 20th April
attachment 2 - 20th April
comment 3 - 9th June
좋아, 그래서 여기 내 첨부 배열 : 이제
$attachments = $issue_json->fields->attachment;
$result1 = array();
foreach ($attachments as $attachment)
{
$result1[] = array
(
'attachment_date' => convert_time($attachment->created),
'attachment_epoch' => convert_sql_time($attachment->created),
'attachment_displayName' => $attachment->author->displayName,
'attachment_filename' => $attachment->filename,
'attachment_file_type' => $attachment->mimeType,
'attachment_thumbnail' => $attachment->thumbnail,
'attachment_url_link' => $attachment->content,
);
}
그 다음에 결과 :
이제Array
([0] => Array(
[attachment_date] => 13th Apr 12 07:10
[attachment_epoch] => 1334301000
[attachment_displayName] => XXX
[attachment_filename] => 1.txt
[attachment_file_type] => text/plain
[attachment_thumbnail] =>
[attachment_url_link] => https://xxx.atlassian.net/secure/attachment/18605/1.txt
)
[1] => Array(
[attachment_date] => 13th Apr 12 07:10
[attachment_epoch] => 1334301000
[attachment_displayName] => xxx
[attachment_filename] => 2.txt
[attachment_file_type] => text/plain
[attachment_thumbnail] =>
[attachment_url_link] => https://xxx.atlassian.net/secure/attachment/18606/2.txt
)
코멘트 :
내가 할 계획했던 이제 어떻게Array ([0] => Array(
[comments_date] => 11th Apr 12 20:52
[comments_epoch] => 1334177520
[comments_displayName] => xxx
[comments_body] => Cannot reproduce, but attempted a fix based on the log file.
)
[1] => Array(
[comments_date] => 13th Apr 12 07:09
[comments_epoch] => 1334300940
[comments_displayName] => xxx
[comments_body] => 1) tested on a bit older version it still happens with it
)
이 두 배열을 병합하지만 일치하는 변수를 가지고 있겠지 때문에 가능 그게 확실하지 메신저했다 :
그리고 여기에 출력의 예입니다.
난 그냥 1 큰 일에 병합하고 내가있는 내가 그 기준으로 정렬 할 시대 날짜 원인을 일치하는 데 필요한 것들을 결합, 그래서 나는 이런 식으로 뭔가있을 때까지 병합 수 :
$result1[] = array
(
'date' => convert_time($attachment->created),
'epoch' => convert_sql_time($attachment->created),
'displayName' => $attachment->author->displayName,
'attachment_filename' => $attachment->filename,
'attachment_file_type' => $attachment->mimeType,
'attachment_thumbnail' => $attachment->thumbnail,
'attachment_url_link' => $attachment->content,
'comments_date' => convert_time($comment->updated),
'comments_epoch' => convert_sql_time($comment->updated),
'comments_displayName' => $comment->author->displayName,
'comments_body' => $comment->body,
);
을
그래서 첫 번째 3은 두 배열이 모두 일치하므로 다른 모든 배열은 첨부 파일이나 주석 모두에 대해 값을 가지지 만 둘 다 가질 수는 없습니다. 한 번 큰 배열이 있으면 에포크별로 정렬하고 연대순으로 결과를 반향시킬 수 있습니다 순서
만약 그렇다면 어떤 병합 명령은 PHP에서 가장 array_merge 또는 재귀 하나? 인스턴트 메신저 아마 이상, PHP는 새로운 인스턴트 메신저에 조금 붙어 이걸로 갈 가장 좋은 방향이 무엇입니까