textarea中的空白

textarea中的空白

问题描述:

I build an array of URLs from the content of a textarea, than process it with simple php dom.

I get this error:

Warning: file_get_contents(http://www.example.com )

Obviously, there is a whitespace at the end of the URL (which is the last in the array and the last in the textarea)

I checked other questions on *, but I still can not get rid of this whitespace and get my script to work, even though my textarea tag contains no whitespaces at all.

This is what my textarea looks like (no whitespace anywhere):

    <textarea id="textarea" name="textarea" value=""></textarea><br><br>

The array is separated by

I even make sure to delete possible whitespaces using the del key after the last entry in the textarea, but I keep getting the same error.

How can I fix this?

我从textarea的内容构建一个URL数组,而不是用简单的php dom处理它。 p >

我收到此错误: p>

 警告:file_get_contents(http://www.example.com)
  code>  pre  > 
 
 

显然,URL的末尾有一个空格(这是数组中的最后一个,也是textarea中的最后一个) p>

我检查了其他问题 在*上,但我仍然无法摆脱这个空白并让我的脚本工作,即使我的textarea标签根本不包含任何空格。 p>

这就是我的textarea的样子( 在任何地方都没有空格): p>

 &lt; textarea id =“textarea”name =“textarea”value =“”&gt;&lt; / textarea&gt;&lt; br&gt;&lt; br&gt;  ; 
  code>  pre> 
 
 

数组由 code> p>分隔

我甚至确保删除可能的 在textarea中的最后一个条目之后使用 del code>键的空格,但是我一直得到同样的错误。 p>

我怎么能 解决这个问题? p> div>

The PHP trim function will do what you need it to. Just change your file_get_contents($url) to file_get_contents(trim($url)) and it should never have that problem.