fopen

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
NiGHTFiRE
Forum Contributor
Posts: 156
Joined: Sun May 14, 2006 10:36 am
Location: Sweden

fopen

Post by NiGHTFiRE »

Hey, this isn't really any code that i'll show, but i'm wondering if you somehow can go to a specefic row number using fopen in the file you are editing?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

you could split the rows into an array and then use the key to identify the row number go from there.
santosj
Forum Contributor
Posts: 157
Joined: Sat Apr 29, 2006 7:06 pm

Post by santosj »

This is pseudo code, so it may not work.

Code: Select all

$contents = file_get_contents($filename);

$row = explode("\n", $contents);

// to access the specific row use the following (row_you_want - 1)
// if you want row 30, then you would get 29

echo $row[29];
NiGHTFiRE
Forum Contributor
Posts: 156
Joined: Sun May 14, 2006 10:36 am
Location: Sweden

Post by NiGHTFiRE »

Thanks, i'll try it.
alex-weej
Forum Newbie
Posts: 19
Joined: Sun May 14, 2006 11:20 am

Post by alex-weej »

Code: Select all

<?php

$file = file('yourfile');

// Echo out line 519
echo $file[519];

?>
Post Reply