টেক্সট ফাইলের শেষ ৫ লাইন মাত্র পড়তে, কোডটি নিম্নরূপ:
উদাহরণ
$file = file("filename.txt"); for ($i = max(0, count($file)-6); $i < count($file); $i++) { echo $file[$i] . "\n"; }আউটপুট
এটি নিচের ফলাফলটি উত্পন্ন করবে:
Given that the file has more than 5 lines of text, the last 5 lines of the text file will be displayed.
ফাইলটি খোলা হয় এবং ফাইলের লাইন সংখ্যা গণনা করা হয়, এবং শেষ লাইন থেকে শুরু করে ৫ লাইন পড়া হয়।