我无法摆脱我的输出php

时间:2014-03-20 03:13:05

标签: php html html5

这是我的html表单

<form method="post" action="parseme.php">
  <textarea name="dadata" cols="40" rows="5" name="myname">
  </textarea>
  <INPUT TYPE="submit" name="submit" />
</form>

这里是php

<?php
  $da_data = (string)$_POST['dadata'];
  $da_data = mb_convert_encoding($da_data, "UTF-8");
  $da_data = str_replace("&nbsp", " ",$da_data);
  $da_data = str_replace("\n", " ", $da_data);
  $da_data = str_replace("\r", " ", $da_data);
  $da_data = str_replace("&nbsp;","", $da_data);
  $da_data = str_replace('<', "[", $da_data);
  $da_data = str_replace(">", "]", $da_data);
  $da_data = str_replace("\"", "", $da_data);
  $da_data = str_replace('\'', "", $da_data);   
  $da_data = str_replace(' ',"", $da_data);
  $da_data = explode(",", $da_data);

  foreach ($da_data as $email) {
    echo $email . "<br>";
  }
?>

我输入的数据会在每一行前面吐出&amp; nbsp。我现在已经在这工作了几个小时。我错过了什么?!?

2 个答案:

答案 0 :(得分:0)

试试这个:

<form method="post" action="parseme.php">
<textarea name="dadata" cols="40" rows="5" name="myname"></textarea>
<INPUT TYPE="submit" name="submit" />
</form>

当谈到textarea时,每个空间都被认可,也尝试:

  <?php
  $da_data = trim($_POST['dadata']); 

答案 1 :(得分:0)

我不知道为什么,但是将它添加到我的php中会删除空格。

$da_data = mb_convert_encoding( $da_data, "HTML-ENTITIES","UTF-8");