Jump to content

[SOLVED] File parsing a line from other server.


Recommended Posts

I guess this is a lot of questions but it is all for one thing I am trying to accomplish. I basically want to get line 49 from a document on a remote server, save it as a variable then run something like a find and replace on that variable and save it as another variable and echo it. The only code I have so far is:

 

<?php
$file = implode('', file('http://server/dir/file.xml'));
echo $file
?>

 

Can anyone help me. I'm still quite new to this.

Do:

$file = file('http://server/dir/file.xml');

echo $file[48]; // line 49

 

file() returns an array of each line in the file.

 

Great, thanks. I was trying that earlier but I didn't realize that you had to put the number down one. Does anyone have any idea to do something along the lines of a find and replace?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.