Hey çocuklar. Ben basit bir blog inşa ediyorum ve benim veri bir dizi benim veritabanından dönen var. Ben her blog yazısı ile ilgili yorumları göstermek istiyorum ama bir döngü içinde bu organize nasıl emin değilim. Bu benim bir dizidir:
Array
(
[author] => Administrator
[post] => Testing entry number one
[entry_date] => Fri, 23 Oct 2009
[commenter] => Sally Anderson
[comments] => comment 1 post 1
[comment_date] => October 24th, 2009 at 5:24 AM
[blog_id] => 1
)
Array
(
[author] => Administrator
[post] => Testing entry number two
[entry_date] => Sat, 24 Oct 2009
[commenter] => Sally Anderson
[comments] => comment 1 post 2
[comment_date] => October 24th, 2009 at 5:21 AM
[blog_id] => 2
)
Array
(
[author] => Administrator
[post] => Testing entry number one
[entry_date] => Fri, 23 Oct 2009
[commenter] => Mike
[comments] => comment 2 post 1
[comment_date] => October 24th, 2009 at 5:21 AM
[blog_id] => 1
)
Array
(
[author] => Administrator
[post] => Testing entry number two
[entry_date] => Sat, 24 Oct 2009
[commenter] => Mike
[comments] => comment 2 post 2
[comment_date] => October 24th, 2009 at 5:21 AM
[blog_id] => 2
)
Her sonrası tekrarlar onunla ilişkili yorumların sayısına göre dikkat edin. Bu özel durumda bu dizi her yazı ile ilgili 2 yorum var. Birisi bana bir foreach döngü yazmak yardım edin ki olacaktır her biri için doğru yorumlarla çıkış 2 ileti?
Teşekkürler!
Belki yeterince iyi açıklayan değilim. İşte aradığım budur.
Array
(
[author] => Administrator
[post] => Testing entry number one
[entry_date] => Fri, 23 Oct 2009
[commenter] => Sally Anderson
[comments] =>
**[0] => Array
(
comment 1 post 1
comment 2 post 1
)**
[comment_date] => October 24th, 2009 at 5:24 AM
[blog_id] => 1
)