嘿傢伙我昨天有一個想法。你能幫我解決這個問題嗎? 下面是代碼使用哪裏在foreach循環在php
foreach($categoriesDetail as $categories)
{
foreach($subCategoriesDetail as $subCategories)
{
if($categories->id == $subCategories->cat_id)
{
foreach($teamsDetail as $team)
{
if($subCategories->id == $team->sub_cat_id)
{
echo $team->name;
}
}
}
}
}
意願將運行併產生correcr結果,但我想額外iteratinos不運行。換句話說
foreach($categoriesDetail as $categories)
{
foreach($subCategoriesDetail as $subCategories where $categories->id == $subCategories->cat_id)
{
foreach($teamsDetail as $team where $subCategories->id == $team->sub_cat_id)
{
echo $team->name;
}
}
}
我知道這是不可能的PHP或任何其他語言,但我想替代或可在未來他們可能會添加此來提高性能。
問題是????? – 2012-03-22 06:02:55
需要減少迭代以提高性能。 – 2012-03-22 12:01:19