Textarea whitespaces

我的未来我决定 提交于 2019-12-11 06:46:39

问题


Every time I update my form textarea the form addes a white space. This is a probleem because I use the textarea input to create a new array element with every new line that the user uses.

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>

Functions:

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;
   }  

}


回答1:


You have whitespace in your html. Change to this

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


来源:https://stackoverflow.com/questions/23824681/textarea-whitespaces

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!