PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today!
  #1  
Old September 29th, 2002, 09:23 PM
mycro mycro is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 1 mycro User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Displaying text from bottom up

How do I display a text file backward from the last line to line 1. i am trying to display latest results on top.

thanks

Reply With Quote
  #2  
Old September 30th, 2002, 12:00 AM
webhappy webhappy is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Silicon Valley, CA, USA
Posts: 203 webhappy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Displaying text from bottom up

Ahaha, I remember doing a function for a CS test last year:

It was a recursive function, so it would input a line, save it to a variable and then recurse; it would then echo the line out.

To grab a line in PHP, use $temp = fgets($fp); //open $fp using fopen

However, I would probably just grab all lines as an array. Fastest way:
http://www.php.net/manual/en/function.file.php

Reply With Quote
  #3  
Old September 30th, 2002, 07:53 AM
sarah's Avatar
sarah sarah is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Auckland, New Zealand
Posts: 127 sarah User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 5 m 32 sec
Reputation Power: 2
Send a message via ICQ to sarah Send a message via AIM to sarah Send a message via Google Talk to sarah
RE: Displaying text from bottom up

Interesting that you posted this at two different forums! or is it that I only found it at 2?

Reply With Quote
  #4  
Old September 30th, 2002, 01:41 PM
D1NGO D1NGO is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Perth, Australia
Posts: 221 D1NGO User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Displaying text from bottom up

lol, i found this post at phpfreaks.com aswell..no harm though, just like buying a lotto ticket with more numbers

Reply With Quote
  #5  
Old September 30th, 2002, 05:33 PM
notepad notepad is offline
Codewalkers Loyal (3000 - 3499 posts)
 
Join Date: Apr 2007
Location: Central, IL USA
Posts: 3,214 notepad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via AIM to notepad
RE: Displaying text from bottom up

even using "file" you'd still need the array_reverse function i think. considering it's stored from top to bottom by default.

Reply With Quote
  #6  
Old September 30th, 2002, 07:39 PM
Nimco Nimco is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 132 Nimco User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to Nimco
RE: Displaying text from bottom up

Surely you can just load it into an array using file() and then run code as follows:
php Code:
Original - php Code
  1.  
  2. <?php
  3. for ($i=(count($array)-1); $i>=0; $i--)
  4.  {
  5.   echo $array[$i] . "rn";
  6.  }
  7. ?>

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Displaying text from bottom up


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway