Get each line from textarea that contains links with PHP

Marsha

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.

Ivar

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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Remove newlines from each line of a text file that contains links and display those links in an iframe

php read from textarea each line doesn't work why?

How to get the last line from JSON file which contains only tuples in each line

Laravel get each line from textarea and save the values in array to send to model

How to get a callback from TextArea on each change?

get entire line from a textarea and editable div

How to get line breaks from textarea

Get same line from two textArea?

jQuery each line in textarea

Django show list of strings in textarea, each string from new line

How to get frequency of logging using bash if each line contains a timestamp?

Max Length for Each Line in Textarea

Creating a string array that contains each line from a file in C#

Laravel get each of lines from textarea and insert into new row in database

removing line by line from textarea

Get a substring from each text line

Get text from each line in RichTextBox?

how can I split the text in the textarea for each line, and save at database? PHP

Get the entire line from a file which contains a number and string

How to get and send values from html <textarea> to a PHP page?

Split value from textarea by line break and add text indent to each of them (Javascript)

Line up input, select, textarea to each other

create if statement on each individual line of a textarea object

how to remove first character in each line of textarea

How to print each line in textarea with javascript?

Remove first line from Textarea

Read new line from textarea

Get all links that contains a specific word in it

Plotly: How to create a line plot from a pandas DataFrame where each cell contains a list?