如何從txt文件讀取特定行數?例如,我有一個有100行的txt文件,我需要打印25或50行到我的網站?我搜索了網站,無法找到如何使用PHP或JavaScript做到這一點。謝謝!從文件讀取可變行數php
現在我有
<?php
if(isset($_GET['submit']))
{
$pavadinimas = htmlentities($_GET['pavadinimas']);
$result = Myfunction($pavadinimas);
$string = file_get_contents("istorija.txt");
$array = explode(PHP_EOL, $string);
function Myfunction($pavadinimas){
For($i=0;$i<=$pavadinimas($array);$i++){
echo $array[$i] ."<br>\n";
}
}
}
?>
<?php if(isset($result)) echo $result; //print the result above the form ?>
<form action="administratorius.php" method ="GET" >
Įrašų skaičius:
<input type="text" name="pavadinimas" maxlength="30" value="<?php echo $form->value("pavadinimas"); ?>"> <br>
<input type="submit" name="submit" value="Prideti">
</form>
我想,我的輸入將作爲函數的變量。我如何使它工作?謝謝!
你能告訴我們你試過了什麼嗎? – DevDonkey