Jump to content

Parsing and sending text separately to another file


1bigbear

Recommended Posts

Hi

 

I have a file that contains a list of links in text, like this

http://www.phpfreaks.com/forums/11

http://www.phpfreaks.com/forums/1555

without the x

 

The page source code looks like this

<link>http://www.phpfreaks.com/forums/11</link><br/>

<link>http://www.phpfreaks.com/forums/1</link><br/>

 

I want to parse the text and send each link to another script, but I don't know how to do this, could you help me.

 

 

 

Link to comment
Share on other sites

If the file your reading looks like this...

 

 

... then you could use something like...

 

$input = file_get_contents($path);
preg_match_all("~<link>(.*)?</link>~", $input, $output);
// the links you then want are stored in $output[1] as an array.

Link to comment
Share on other sites

No, I don't understand what your asking. Why is the search in a seperate script to where you need it, why not just put it in the same script. If there is a reason for it to be in a seperate script then you will need to use either $_SESSION variables to pass information between scripts or depending on the nature of teh scripts use the include function to bring the other scripts functions into scope.

Link to comment
Share on other sites

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.