Jump to content

Split File Data


Dysan

Recommended Posts

I'd read them into an array using file() then use array_slice() to the get the six I want to display depending on page number. You'll need extra code, but this is main bit

<?php 
$names = file('mynames.txt');                                           // read text into an array
$total_pages = ceil(count($names)/6);
$offset = ($page-1)*6;                                                  // get offset from page number
$page_names = array_slice($names, $offset, 6);                          // get array of the 6 names on this page
?>

Link to comment
https://forums.phpfreaks.com/topic/106971-split-file-data/#findComment-548312
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.