空白文本区域


Textarea whitespaces

每次我更新表单文本区域时,表单都会添加一个空白。这是一个问题,因为我使用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;
   }  

}

你的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>