Welcome to dbForumz.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

How to pick a specific row in a file?

 
   Database Forums (Home) -> PHP RSS
Next:  PHP SMTP-Auth  
Author Message
Roger Saarva

External


Since: Jul 31, 2004
Posts: 1



(Msg. 1) Posted: Sat Jul 31, 2004 3:56 pm
Post subject: How to pick a specific row in a file?
Archived from groups: alt>comp>lang>php (more info?)

Hello..

Lets say I want to pick row number #3 in text.txt.

$row[] = file['text.txt'];

How to do now..? Razz

Thanks alot in Advance.

 >> Stay informed about: How to pick a specific row in a file? 
Back to top
Login to vote
steve




Joined: Jan 06, 2004
Posts: 655



(Msg. 2) Posted: Sat Jul 31, 2004 4:32 pm
Post subject: Re: How to pick a specific row in a file? [Login to view extended thread Info.]

Roger Saarva wrote:
Hello..

Lets say I want to pick row number #3 in text.txt.

$row[] = file['text.txt'];

How to do now..? Razz

Thanks alot in Advance.


$row[2] is the element you are looking for. One less than 3 since the array is zero-based.

 >> Stay informed about: How to pick a specific row in a file? 
Back to top
Login to vote
Colin McKinnon

External


Since: Apr 21, 2004
Posts: 38



(Msg. 3) Posted: Sat Jul 31, 2004 7:53 pm
Post subject: Re: How to pick a specific row in a file? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

steve spilled the following:

 > "Roger Saarva" wrote:
  > > Hello..
  > >
  > > Lets say I want to pick row number #3 in text.txt.
  > >
  > > $row[] = file[’text.txt’];
  > >
  > > How to do now..?
  > >
  > > Thanks alot in Advance.
 >
 > $row[2] is the element you are looking for. One less than 3 since the
 > array is zero-based.
 >

Nope - coz he assigned the array of lines to the next free elemnt in the
array - using the code above, the OP really wants $row[*something*][2]...

I expect he really meant to write:
$row=file('text.txt');

C.<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: How to pick a specific row in a file? 
Back to top
Login to vote
Andreas Saarva1

External


Since: Aug 01, 2004
Posts: 3



(Msg. 4) Posted: Sat Jul 31, 2004 8:53 pm
Post subject: Re: How to pick a specific row in a file? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Colin McKinnon"
<colin.thisisnotmysurname.RemoveThis@ntlworld.deletemeunlessURaBot.com> skrev i
meddelandet news:YoWOc.418$E25.268@newsfe3-gui.ntli.net...
 > steve spilled the following:
 >
  > > "Roger Saarva" wrote:
   > > > Hello..
   > > >
   > > > Lets say I want to pick row number #3 in text.txt.
   > > >
   > > > $row[] = file['text.txt'];
   > > >
   > > > How to do now..?
   > > >
   > > > Thanks alot in Advance.
  > >
  > > $row[2] is the element you are looking for. One less than 3 since the
  > > array is zero-based.
  > >
 >
 > Nope - coz he assigned the array of lines to the next free elemnt in the
 > array - using the code above, the OP really wants $row[*something*][2]...
 >
 > I expect he really meant to write:
 > $row=file('text.txt');
 >
 > C.

Hmm... let's start it from the beginning... hehe sorry for that, but
anyways...

Lets assume I want to have the row 127 in the html code of a site assigned
in the variable $row_127, lets say <a style='text-decoration: underline;' href="http://www.example.com," target="_blank">www.example.com,</a> then how would I have to
write?

Thank you.<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: How to pick a specific row in a file? 
Back to top
Login to vote
Hilarion

External


Since: Mar 22, 2004
Posts: 124



(Msg. 5) Posted: Mon Aug 02, 2004 11:54 am
Post subject: Re: How to pick a specific row in a file? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

<?php
$row_127 = file('text.txt')[126];
?>

or

<?php
$rows = file('text.txt');
$row_127 = $rows[126];
?>

or

....
 >> Stay informed about: How to pick a specific row in a file? 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Stop hotlinking to a specific file & keeping a counter - Hi, How can I stop hotlinking to a specific file, and I want it to redirect it to a PHP link so I can monitor the number of downloads. Here is my site with the download page: http://www.adhal.org/software/downloads.htm And here is softpedia directl...

how do you open a file with quote marks in the file name o.. - I've got a client that is a music studio and they've several thousand mp3s that tend to have file names like this: Adrian Orange - Bitches Is Lord - 13 - Don't Get Used To It.mp3 The quote mark in that file name is giving me trouble. The music studio....

want to get content of one php file in another php file - i have one php file having content Contents of ex1.php file <body> <?php $content = "c://webserver/www/abc.php"; $handle = fopen($content, "r"); echo fread($handle,filesize($content)); ?> </body> this is reading abc...

getting the name of the PHP file - Hi! I am a PHP beginner, and I don't know my way around. Let's say I have a file named as "file.php". Is there a special variable that already includes the file name, or should I just manually code it into the script; i.e. $filename = "...

File selection? - I'm running some php scripts locally (Windoze XP) to operate on local files and, at least partly because I can't seem to access the parameters via argv[] or get it to print out in my DOS box, it seems sensible to run it via a web page (I'm running..
   Database Forums (Home) -> PHP All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]