cgimusic Posted September 15, 2008 Share Posted September 15, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/124374-solved-file-parsing-a-line-from-other-server/ Share on other sites More sharing options...
wildteen88 Posted September 15, 2008 Share Posted September 15, 2008 Do: $file = file('http://server/dir/file.xml'); echo $file[48]; // line 49 file() returns an array of each line in the file. Quote Link to comment https://forums.phpfreaks.com/topic/124374-solved-file-parsing-a-line-from-other-server/#findComment-642318 Share on other sites More sharing options...
cgimusic Posted September 15, 2008 Author Share Posted September 15, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/124374-solved-file-parsing-a-line-from-other-server/#findComment-642322 Share on other sites More sharing options...
wildteen88 Posted September 15, 2008 Share Posted September 15, 2008 Remembers arrays start at 0 not 1. PHP has a number of functions on text manipulation. What are you trying to find and replace? Can you give an example. Quote Link to comment https://forums.phpfreaks.com/topic/124374-solved-file-parsing-a-line-from-other-server/#findComment-642323 Share on other sites More sharing options...
cgimusic Posted September 15, 2008 Author Share Posted September 15, 2008 Actually I managed to work it out. I used str_ireplace. Thanks for your help. Quote Link to comment https://forums.phpfreaks.com/topic/124374-solved-file-parsing-a-line-from-other-server/#findComment-642331 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.