You could use this piece of code to get a few ideas :
<?php
this could be your textfile in a string
$input = 'abc|def|ghi|jkl|mno|pqr|stu|vw|xyz|';
// splits the input at every | into an array
$data = explode('|', $input);
// find the lowest and highest element to print
$max = count($data);
$min = $max - 5;
if ($min < 0) {
$min = 0; // for safety
}
// show elements from min to max
for($element=$min; $element<$max; $element++) {
echo "Element |$element| = |".$data[$element]."<br>\n";
}
?>
If this doesn't help you or you'd like more help - feel free to contact me. I'll be watching the emails!