🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.comp.lang.php
Article #54

Re: How do I do this?

#54
From: jbp
Date: Wed, 23 May 2001 22:50
30 lines
1780 bytes
===== Original Message from: Jan- =====

>I want to display only the last line of a txt-file.
>Ex. I have a txt-file named 'lines.txt' and it contains this:
>
>This is line one
>This in line two
>This is line three
>
>
>Now I wanna make a php script that only displays the last line so only 'This
>is line three'.
>How do I do this, is it possible?

<?php
$lines = file(lines.txt);
echo $lines[sizeof($lines)-1];
?>

or

<?php
$lines = file(lines.txt);
echo $lines[sizeof($lines)];
?>

depending on whether your text file has a trailing cr/lf.

-- 
Joseph Birr-Pixton .:|:. http://ifihada.com .:|:. ICQ#40675236
Technical Details
Message-ID: <9efogt04fd89qalgmhc6bao25f0guub95m@4ax.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!130.133.1.3!fu-berlin.de!uni-berlin.de!acab9e8e.ipt.aol.COM!not-for-mail
References: <kZWO6.8315$FL1.909094@afrodite.telenet-ops.be>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1107bb,39486179625bfc13
X-Google-Attributes: gid1107bb,public
X-Google-Thread: 10f92b,39486179625bfc13
X-Google-Attributes: gid10f92b,public
X-Google-Thread: 1156bd,39486179625bfc13
X-Google-Attributes: gid1156bd,public
X-Google-Thread: f9981,39486179625bfc13
X-Google-Attributes: gidf9981,public
X-Google-ArrivalTime: 2001-05-23 15:48:55 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!130.133.1.3!fu-berlin.de!uni-berlin.de!acab9e8e.ipt.aol.COM!not-for-mail
From: jbp <jpixton@dircon.co.uk>
Newsgroups: alt.comp.lang.php,alt.php,cz.comp.lang.php,de.comp.lang.php
Subject: Re: How do I do this?
Date: Wed, 23 May 2001 23:50:27 +0100
Lines: 30
Message-ID: <9efogt04fd89qalgmhc6bao25f0guub95m@4ax.com>
References: <kZWO6.8315$FL1.909094@afrodite.telenet-ops.be>
NNTP-Posting-Host: acab9e8e.ipt.aol.com (172.171.158.142)
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Trace: fu-berlin.de 990658134 3193088 172.171.158.142 (16 [75689])
X-Newsreader: Forte Agent 1.8/32.548