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.

 

 

 

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.

If I ad echo $output[1]; to show what did he get

$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.
echo $output[1];

 

I get this result

 

Array

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.

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.