php relative output problem - 12/14/2003 7:02 AM
I have a news program that outputs the link to news coming from the state on new regulations. The link that is generated shows up as one on my site which is wrong. I need it to insert the proper url... example
proper link should look like this
http://www.wa.gov/wdfw/fish/regs/regchng/dec0903a.htm
but returns a link like this in my pal box
http://www.steelheader.net/ubbthreads/regchng/nov1903c.htm
I do a include from the txt file... should be a easy fix but its beyond me.
proper link should look like this
http:/
but returns a link like this in my pal box
http:/
I do a include from the txt file... should be a easy fix but its beyond me.
Code
<?<br /><br />$filename ="wdfw_data.txt";<br />$handle= fopen($filename,'w');<br />$url="http://www.wa.gov/wdfw/fish/regs/fishregs.htm";<br />$result = shell_exec("wget -q -O - $url");<br /><br />$contents = Implode("", File($url));<br />preg_match_all("|<a\b([^>]+)>(.*?)</a>|i", $contents, $arrayoflinks);<br /><br />$x=1;<br />$pattern = "/\.\/regchng/i";<br />$replacement = "http://www.wa.gov/wdfw/fish/regs/regchng";<br /><br />while(List(,$link) = Each($arrayoflinks[0])){<br /> if (preg_match ("/regchng/i", "$link")) {<br /> if($x<11){<br /> $link = preg_replace($pattern, $replacement, $link);<br /> $resulting_data .= "$link<br>";<br /> }<br /> $x++;<br /> }<br />}<br /><br /><br /><br />fputs($handle, $resulting_data);<br /><br />exit;<br />?><br /><br />