icon Get the most out of Surmunity, read our tips here! Need an interesting blog to read? You've got to read the Surpass Blog! | Welcome! Please register to access all of our features.

» Surpass Web Hosting Forums » Discussions » PHP, MySQL » is it possible to read a certian line

PHP, MySQL General PHP questions. Or go to our PHPsuexec Forum >>

Closed Thread
 
LinkBack Thread Tools Search this Thread Rate Thread
Old July 15th, 2003, 1:51 AM   #1 (permalink)
Undercover Genius
Super #1
 
FyreFox's Avatar
 
Joined in May 2003
Lives in Tampa, FL
Hosted on Vanilla
3,055 posts
Gave thanks: 27
Thanked 38 times
from a text file?

Okay, I want to have a txt file right. but on the page, I only want to use certain lines, is there a way to name and read only certain line #'s?

Example...

Txt file:

Line - Text
1 - Name
2 - Link
3 - Name
4 - Link
Etc

Page:

In a table, I think i'd have a loop will take the odd line numbers to print the names on one side, then the even numbers as the links on the other side of the table.

Get what I'm saying? LoL :pleasehelp:
__________________
When one door of happiness closes, another opens; but often we look so long at the closed door that we do not see the one which has been opened for us. - Helen Keller
FyreFox is online now  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old July 15th, 2003, 2:07 AM   #2 (permalink)
Registered User
Seasoned Poster
 
Joined in Jun 2003
69 posts
Gave thanks: 0
Thanked 0 times
huh?.....LOL
__________________
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
-Rich Cook

"UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity."
-Dennis Ritchie.

"Beware of computer programmers that carry screwdrivers."
-Leonard Brandwein.
pita0017 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old July 15th, 2003, 2:09 AM   #3 (permalink)
Undercover Genius
Super #1
 
FyreFox's Avatar
 
Joined in May 2003
Lives in Tampa, FL
Hosted on Vanilla
3,055 posts
Gave thanks: 27
Thanked 38 times
Quote:
Originally posted by pita0017Jul 15 2003, 1.07 am
huh?.....LOL
okay, like put the contents of the text file into an array maybe? each line in the text file would be a different element in the array? does that make more sense?
__________________
When one door of happiness closes, another opens; but often we look so long at the closed door that we do not see the one which has been opened for us. - Helen Keller
FyreFox is online now  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old July 15th, 2003, 9:50 AM   #4 (permalink)
the one who was
Super #1
 
patrickb's Avatar
 
Joined in Jul 2003
Lives in Memphis
1,967 posts
Gave thanks: 0
Thanked 3 times
It would be quite possible. Use the file() function of php, it loads the entire file into an array.

$arrayFile = file("//readme.txt");

Then you want to read line 3, just do 3 - 1 (arrays use zero based indexes) and call the array with that number.

$line = $arrayFile[2] // This would read line #3 from the text file.


I would suggest thinking about doing a different format for the name/link combo you are describing. Instead of putting each one on a different line, put them on the same line. Maybe make a comma the delimiter between the two. Then for each line you read in, explode() it and you got it. No real advantages there, but its better scripting practice for the future when you start reading in more complicated stuff...
__________________
Patrick

Warnings: The program(s) might crash unexpectedly or behave otherwise strangely. (But of course, so do many commercial programs on Windows.) --www.gimp.org
patrickb is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old July 15th, 2003, 1:48 PM   #5 (permalink)
Undercover Genius
Super #1
 
FyreFox's Avatar
 
Joined in May 2003
Lives in Tampa, FL
Hosted on Vanilla
3,055 posts
Gave thanks: 27
Thanked 38 times
Quote:
Originally posted by patrickbJul 15 2003, 8.50 am
It would be quite possible. Use the file() function of php, it loads the entire file into an array.

$arrayFile = file("//readme.txt");

Then you want to read line 3, just do 3 - 1 (arrays use zero based indexes) and call the array with that number.

$line = $arrayFile[2] // This would read line #3 from the text file.


I would suggest thinking about doing a different format for the name/link combo you are describing. Instead of putting each one on a different line, put them on the same line. Maybe make a comma the delimiter between the two. Then for each line you read in, explode() it and you got it. No real advantages there, but its better scripting practice for the future when you start reading in more complicated stuff...
Okay, THANK YOU VERY MUCH! :goodmood:
__________________
When one door of happiness closes, another opens; but often we look so long at the closed door that we do not see the one which has been opened for us. - Helen Keller
FyreFox is online now  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On