How do I read specific number of lines from a txt file? For example I have a txt file which has 100 lines, and I need to print 25 or 50 lines to my website? I searched website and was not able to find how to do this using php or javascript. Thanks!
For now I have
<?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>
";
}
}
}
?>
<?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>
I want that my input would be as a variable for function. How do I make it work? Thanks!