Horje

How to extract first 100 records from a TXT file in PHP

Follow the Example
index.php
Example: PHP
<?php
$start = 1; 
$end = 100;
$handle = fopen("file.csv", "r");
$i = 0;
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
if(($start <= $i) && ($i <= $end)) {

    
    echo $data[0];
    echo '</br>';
    
}
elseif($i > $end) {
    break;
}
$i++;
}

fclose($handle);
?>

Output should be:

How to extract first 100 records from a TXT file in PHP



Related Articles
How to extract Domain Name from Full URL in PHP PHP Extract Tutorial
How to extract only name from domain in PHP PHP Extract Tutorial
How to extract All url from a single page by PHP PHP Extract Tutorial
How to get first Five Line from CSV File PHP Extract Tutorial
How to get first 100 records from a csv file in PHP PHP Extract Tutorial
How to get meta Tag PHP Extract Tutorial


Type:
Php
Category:
Web Tutorial
Sub Category:
PHP Extract Tutorial
Uploaded by:
Admin



Share on: