从textarea获取包含PHP链接的每一行
This question solved my problem only until getting each line from textarea. But when I access the link (what contains in each line) with simplexml_load_file
to get the data, the link started to end with unique codes:
foreach ($textAr as $line) {
echo $line = trim($line)."<br/>"; //I trim it again just to make sure, and the result is the right link.
echo $xml = simplexml_load_file($line)."<br/>"; //code like %3Cbr/%3E showed up at the end of the link
}
And the error is something like:
A PHP Error was encountered
Severity: Warning
Message: simplexml_load_file(link%3Cbr/%3E) [function.simplexml-load-file]: failed to open stream: HTTP request failed!
I replace the real link with link on the error message.
How to remove the unique codes (%3Cbr/%3E)? I've tried str_replace("%3Cbr/%3E","",$line)
but it's not working.
It is just a matter of removing .<br/>
echo $line = trim($line);
The %3Cbr/%3E
represents the <br/>
The reason why str_replace("%3Cbr/%3E","",$line)
doesn't work, is because the line does not contain %3Cbr/%3E
. It contains <br/>
. Only if the link tries to open it, it will encode the url, replacing the <
and >
signs, which makes it 3Cbr/%3E
.
I'm not sure if you mean to also print all the lines, but if you don't, you can remove the echo
.