mysql データベースから記事情報を取得すると、次のような配列が得られました。
Array
(
[0] => Array
(
[CategoryID] => 3
[CategoryName] => Test Category
[Parent] => 0
[Thumb] => 0
[sort] => 8
[ArticleID] => 2
[ArticleCatgories] => 9,4,3
[ArticleTitle] => vxcvxcvx
[ArticleBody] => xcvxcvxcvxcv
[InGroup] => 0
[GroupID] => 0
[Published] => 1
[PublishTime] =>
[TermID] => 11
[TermSlug] => xcvxcvxcv
[RelatedID] => 2
[TermType] => article
)
[1] => Array
(
[CategoryID] => 4
[CategoryName] => Test Image
[Parent] => 0
[Thumb] => 0
[sort] => 4
[ArticleID] => 2
[ArticleCatgories] => 9,4,3
[ArticleTitle] => vxcvxcvx
[ArticleBody] => xcvxcvxcvxcv
[InGroup] => 0
[GroupID] => 0
[Published] => 1
[PublishTime] =>
[TermID] => 11
[TermSlug] => xcvxcvxcv
[RelatedID] => 2
[TermType] => article
)
[2] => Array
(
[CategoryID] => 9
[CategoryName] => Test Images
[Parent] => 0
[Thumb] => 7
[sort] => 2
[ArticleID] => 2
[ArticleCatgories] => 9,4,3
[ArticleTitle] => vxcvxcvx
[ArticleBody] => xcvxcvxcvxcv
[InGroup] => 0
[GroupID] => 0
[Published] => 1
[PublishTime] =>
[TermID] => 11
[TermSlug] => xcvxcvxcv
[RelatedID] => 2
[TermType] => article
)
}
また、記事は複数のカテゴリに属しているため、記事の情報を複数回取得します。私がする必要があるのは、結果が次のようになるように、同じ ArticleID を持つ場合、カテゴリ名をサブ配列に結合することです。
Array
(
[0] => Array
(
[CategoryName] => array('Test Category','Test Image','Test Images');
[Parent] => 0
[Thumb] => 0
[sort] => 8
[ArticleID] => 2
[ArticleCatgories] => 9,4,3
[ArticleTitle] => vxcvxcvx
[ArticleBody] => xcvxcvxcvxcv
[InGroup] => 0
[GroupID] => 0
[Published] => 1
[PublishTime] =>
[TermID] => 11
[TermSlug] => xcvxcvxcv
[RelatedID] => 2
[TermType] => article
)
}