| PHP, MySQL General PHP questions. Or go to our PHPsuexec Forum >> |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread |
|
|
#1 (permalink) |
|
Undercover Genius
Super #1
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 |
|
|
|
|
#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. |
|
|
|
|
#3 (permalink) | |
|
Undercover Genius
Super #1
Joined in May 2003
Lives in Tampa, FL
Hosted on Vanilla
3,055 posts
Gave thanks: 27
Thanked 38 times
|
Quote:
__________________
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 |
|
|
|
|
|
#4 (permalink) |
|
the one who was
Super #1
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 |
|
|
|
|
#5 (permalink) | |
|
Undercover Genius
Super #1
Joined in May 2003
Lives in Tampa, FL
Hosted on Vanilla
3,055 posts
Gave thanks: 27
Thanked 38 times
|
Quote:
__________________
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 |
|
|
|