Skip to content

Instantly share code, notes, and snippets.

@tobiastom
Created October 26, 2009 14:47
Show Gist options
  • Select an option

  • Save tobiastom/218707 to your computer and use it in GitHub Desktop.

Select an option

Save tobiastom/218707 to your computer and use it in GitHub Desktop.
1. dfkadsjfsdfdsf
2. dsflkajsdlkfjads
3. asdlkfjlaksdfj
4. adsfklajasdlkfj
5. dsafkjadlskf
6. sdflkjadsf
7. adsfkljdsfdsfas
8. sadfkljadslkfj
9. adsfkjdslkf
10. dsfjasdöf
11. sdfkjdsf
12. dslfköödsalf
13. dsflöadsfdsf
<?php
$itemsPerPage = 2;
$page = 7;
$content = file('foo.txt');
$index = count($content)-($itemsPerPage*$page);
$itemOnPage = 0;
if ($index < 0) {
$itemOnPage = abs($index);
$index = 0;
}
$data = array();
for($x = $itemOnPage; $x < $itemsPerPage; $x++) {
$data[] = trim($content[$index++]);
}
print_r($data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment