Jump to content

How do you fetch and modify data?


waiwai933

Recommended Posts

I want to fetch data from a website, which I think is easy enough, but here's the tough part. How do I not get that outputted, but instead, strip the first ten lines, the last ten lines, and then output it? You see, the data to be fetched is the source code, so...

 

Sorry if this is a stupid question, but I'm new to PHP.

Link to comment
https://forums.phpfreaks.com/topic/133737-how-do-you-fetch-and-modify-data/
Share on other sites

what do you mean you want to fetch data? you mean you want to connect to a db? where do you want to output to?

 

No, there's a webpage I have on a different server that changes, and I need my first webpage to change with it. I just need it to output to the page. Like say if I sent input abcde, and it removed the first character, I would want the page to be example.com/output.php with the text being bcde.

 

use file  function and get the desired array index you want

 

I'm sorry? I don't quite understand you.

 

ok, so, you want a page on one server to mirror the page on the other? and you have access to both servers?

and if it changes you want the other to change? and when something changes on it will it have to be live? or will it have to be after the page is refreshed/ posted?

 

myself, i have no idea how to go off the number of lines, but i am sure if you counted the number of characters

you would be able to loop through and delete how ever many characters you wanted from the page with much ease. If you want it to update live it might be harder you might need something fancy like ajax.

 

just a idea and i am sure alot of people here could think of a much better way to do it.

 

but perhaps since many others havnt suggested anything i would say try.

 

post all the characters of the page to your new page as a variable --> loop through and append / delete how ever many characters you want from which ever place on the page you want --> echo the newly modified variable to the page in html so that your php page can generate the old page with the modifications that you wanted.

 

post all the characters of the page to your new page as a variable --> loop through and append / delete how ever many characters you want from which ever place on the page you want --> echo the newly modified variable to the page in html so that your php page can generate the old page with the modifications that you wanted.

 

This would work. How do I do it?

well, it depends,

 

because you may not be able to actually post across servers I do not know about that. (if it dosnt work it dosnt matter because you could post the script to a db and then tap into it from the other site and withdraw it).

 

if you want to do it my way then,

 

You need to read up about posting variables (if that dosnt working then learn about inserting / selecting from a db)

then running through the number of characters you want to cull.

 

what exactly do you want to know?

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.