【问题标题】:Textarea whitespaces文本区域空格
【发布时间】:2014-05-23 08:43:45
【问题描述】:

每次我更新表单 textarea 时,表单都会添加一个空格。这是一个问题,因为我使用 textarea 输入为用户使用的每一行创建一个新的数组元素。

HTML:

<textarea class='form-control input-lg' name='stout' style='width:100%;min-height:200px;resize: none; '> 
     <?php $a = $functie-  >_getFileContent('../content/stout.txt', 'j');
     echo $bewerking->_extraInfoInput($a);?>
</textarea>

功能:

public function _extraInfoInput($a){
    $a = preg_replace('/ /', '', $a);

    return $a;
}

 public function _getFileContent($file,$uitzondering){       
   $content = file_get_contents($file);        
   if($content != ''){
       if($uitzondering == ''){
           $a = $content.'<br/>';
       }
       else{

           $a = $content;

       }
       return $a;
   }  

}

【问题讨论】:

  • 什么是 jsfiddle.net?
  • 是一个展示代码的网站。但直到现在我才看到你有 php 代码。但我认为 jsfiddle 无法运行 php 代码

标签: php html textarea whitespace


【解决方案1】:

您的 html 中有空格。改成这个

<textarea class='form-control input-lg' name='stout' style='width:100%;min-height:200px;resize: none;'><!-- no whitespace here--><?php $a = $functie-  >_getFileContent('../content/stout.txt', 'j');
 echo $bewerking->_extraInfoInput($a);?><!-- or here --></textarea>

【讨论】:

  • 所以如果我在
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-03-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-31
  • 1970-01-01
  • 2020-07-02
相关资源
最近更新 更多