У меня есть три stdClass
массива объектов, которые хранятся в отдельных переменных. Я хочу просмотреть их, так как для каждой итерации массива 1 я хочу, чтобы все индексы из массива 2 - где Season_id
в массиве 2 будут равны Season_id
в массиве 1.
Затем для каждой итерации массива 2 я хочу, чтобы все индексы из массива 3 - где Episode_id
в массиве 3 будет равен Episode_id
в массиве 2.
Это мои массивы
Array
(
[0] => stdClass Object
(
[Season_id] => 1
[Season_number] => 1
[TV_Show_id] => 1
)
[1] => stdClass Object
(
[Season_id] => 2
[Season_number] => 2
[TV_Show_id] => 1
)
[2] => stdClass Object
(
[Season_id] => 3
[Season_number] => 3
[TV_Show_id] => 1
)
)
------------------- 2-й массив ---------------------
Array
(
[0] => Array
(
[0] => stdClass Object
(
[Episode_id] => 1
[Episode_title] => Pigeon Post
[Episode_number] => 2
[Season_id] => 1
)
[1] => stdClass Object
(
[Episode_id] => 2
[Episode_title] => The British ave Come (The Fallen Madonna)
[Episode_number] => 1
[Season_id] => 1
)
)
[1] => Array
(
[0] => stdClass Object
(
[Episode_id] => 3
[Episode_title] => The Gateau From The Chateau
[Episode_number] => 7
[Season_id] => 2
)
[1] => stdClass Object
(
[Episode_id] => 4
[Episode_title] => Herr Flicks Revenge
[Episode_number] => 6
[Season_id] => 2
)
[2] => stdClass Object
(
[Episode_id] => 5
[Episode_title] => The Duel
[Episode_number] => 5
[Season_id] => 2
)
[3] => stdClass Object
(
[Episode_id] => 6
[Episode_title] => Swiftly and With Style
[Episode_number] => 4
[Season_id] => 2
)
)
[2] => Array
(
[0] => stdClass Object
(
[Episode_id] => 10
[Episode_title] => The Great Un-Escape
[Episode_number] => 6
[Season_id] => 3
)
[1] => stdClass Object
(
[Episode_id] => 11
[Episode_title] => Pretty Maids All In A Row
[Episode_number] => 5
[Season_id] => 3
)
[2] => stdClass Object
(
[Episode_id] => 12
[Episode_title] => Flight of Fancy
[Episode_number] => 4
[Season_id] => 3
)
[3] => stdClass Object
(
[Episode_id] => 13
[Episode_title] => The Sausage In the Wardrobe
[Episode_number] => 3
[Season_id] => 3
)
)
)
------------------------- 3-й массив -------------------- ----------
Array
(
[0] => Array
(
[0] => stdClass Object
(
[Subtitle_id] => 1
[Subtitle_name] => title name
[Subtitle_download_link] => donwload-link.
[Subtitle_language] => english
[Subtitle_version] => FQM
[hearing_impairment] =>
[Episode_id] => 1
)
[1] => stdClass Object
(
[Subtitle_id] => 2
[Subtitle_name] => title name
[Subtitle_download_link] => donwload-link.
[Subtitle_language] => english
[Subtitle_version] => FQM
[hearing_impairment] =>
[Episode_id] => 1
)
[2] => stdClass Object
(
[Subtitle_id] => 3
[Subtitle_name] => title name
[Subtitle_download_link] => donwload-link.
[Subtitle_language] => english
[Subtitle_version] => FQM
[hearing_impairment] =>
[Episode_id] => 1
)
[3] => stdClass Object
(
[Subtitle_id] => 4
[Subtitle_name] => title name
[Subtitle_download_link] => donwload-link.
[Subtitle_language] => english
[Subtitle_version] => FQM
[hearing_impairment] =>
[Episode_id] => 1
)
)
[1] => Array
(
[0] => stdClass Object
(
[Subtitle_id] => 5
[Subtitle_name] => title name
[Subtitle_download_link] => donwload-link.
[Subtitle_language] => english
[Subtitle_version] => FQM
[hearing_impairment] =>
[Episode_id] => 2
)
[1] => stdClass Object
(
[Subtitle_id] => 6
[Subtitle_name] => title name
[Subtitle_download_link] => donwload-link.
[Subtitle_language] => english
[Subtitle_version] => FQM
[hearing_impairment] =>
[Episode_id] => 2
)
[2] => stdClass Object
(
[Subtitle_id] => 7
[Subtitle_name] => title name
[Subtitle_download_link] => donwload-link.
[Subtitle_language] => english
[Subtitle_version] => FQM
[hearing_impairment] =>
[Episode_id] => 2
)
[3] => stdClass Object
(
[Subtitle_id] => 8
[Subtitle_name] => title name
[Subtitle_download_link] => donwload-link.
[Subtitle_language] => english
[Subtitle_version] => FQM
[hearing_impairment] =>
[Episode_id] => 2
)
[4] => stdClass Object
(
[Subtitle_id] => 9
[Subtitle_name] => title name
[Subtitle_download_link] => donwload-link.
[Subtitle_language] => english
[Subtitle_version] => FQM
[hearing_impairment] =>
[Episode_id] => 2
)
[5] => stdClass Object
(
[Subtitle_id] => 10
[Subtitle_name] => title name
[Subtitle_download_link] => donwload-link.
[Subtitle_language] => english
[Subtitle_version] => FQM
[hearing_impairment] =>
[Episode_id] => 2
)
)
[2] => Array
(
[0] => stdClass Object
(
[Subtitle_id] => 11
[Subtitle_name] => title name
[Subtitle_download_link] => donwload-link.
[Subtitle_language] => english
[Subtitle_version] => FQM
[hearing_impairment] =>
[Episode_id] => 3
)
)
)
Я попробовал это. Он отлично работает только для первой итерации массива 1. После этого третий цикл не дает ожидаемых результатов.
for($i=0;$i<sizeof($seasons);$i++)
{
echo $seasons[$i]->Season_id." season id";
echo "<br>";
for($j=0;$j<sizeof($episodes);$j++)
{
if($episodes[$i][$j]->Season_id == $seasons[$i]->Season_id)
{
echo $episodes[$i][$j]->Episode_number." episode id";
echo "<br>";
for($k=0;$k<sizeof($subtitles);$k++)
{
if($subtitles[$j][$k]->Episode_id == $episodes[$i][$j]->Episode_id)
{
echo $subtitles[$j][$k]->Subtitle_id." subtitles id";
echo "<br>";
}
}
}
echo "<br>";
}
echo "<br>";
}
Мне нужен такой результат:
Season 1
Episode 1
Sub Title 1
Sub Title 2
Sub Title 3
Episode 2
Sub Title 1
Sub Title 2
Sub Title 3
Sub Title 4
Season 2
Episode 1
Sub Title 1
Sub Title 2
Sub Title 3
Episode 2
Sub Title 1
Sub Title 2