0

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.

Community
  • 1
  • 1
Marsha
  • 167
  • 3
  • 3
  • 18

1 Answers1

0

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.

Ivar
  • 6,138
  • 12
  • 49
  • 61
  • Oh I see. I meant to see what's inside the `$line` after it trimmed but turns out that the `"
    "` I added is the problem. I removed it and add another line `echo $line."
    ";` Thank you @Ivar
    – Marsha Nov 05 '15 at 09:32