我正在爲我的家族做一個網站。 我想在左邊有一個動態目錄。如何從文本文件讀取時停止foreach()循環?
E.G.如果你點擊「遊戲」鏈接,它應該停止並打印另一個列表。列表中的列表。
我知道,這聽起來很奇怪,我認爲如果我告訴你我的代碼,它會是最好的。
這就是:
<div class="links">
<?php
$zeilen = file ('../inhaltsverzeichnis.txt');
foreach ($zeilen as $zeile)
{
if($zeile == 3)
{
$games = file ('games_inhaltsverzeichnis.txt');
foreach ($games as $game)
{
echo $game;
}
}
else
{
echo $zeile;
}
}
?>
我希望你知道我的意思。
您可以使用'break;'。 – ops
應該按原樣工作。有什麼問題? – deceze
我怎麼能說他應該停止閱讀文本文件時,線路「遊戲」來? –