Hi, i need some help. I have list like this: 22. darkcenter.net <http://darkcenter.net/> 23. daviefla.biz <http://daviefla.biz/> 24. de.world-searchengines.org <http://de.world-searchengines.org/> Code (markup): and so on, about 8000 lines. What i need is replace everything except link between < > and write that link into file, all 8000 lines, with php. I forgot regexp syntax, tried to remember but failed so please write code for this sh*t
<? $file_to_read = "lines.txt"; $file_to_write = "output.txt"; $fh = fopen("$file_to_read", "r"); $i = 1; while ($line = fgets($fh)) { $row[$i] = $line; $i++; } fclose($fh); $fh = fopen($file_to_write, 'w') or die("can't open file"); $a = 1; $max = count($row); while ($a <= $max) { $var[$a] = explode(" ",$row[$a]); $data[$a] = "<a href='http://".$var[$a][1]."'>".$var[$a][1]."</a>\n"; echo $data[$a]; /* fwrite($fh, $data[$a]); */ $a++; } #print_r($row); ?> PHP: We'll, I'm not much good with regex's but, this above should do the trick. Let me know if I need to modify anything. Oh, yeah, remember to uncomment part where it writes to file. What is pasted here could be used for browser output, for test. Also, if you don't need standard link syntax for html, you can modify line where $data variable is being constructed to suit you.