![](/img/trans.png)
[英]Extra white spaces while printing my results in textfield and in Textarea
[英]Removing extra white spaces from beginning of textarea in laravel
對於這種情況,PHP 有一些內置函數。 在答案的最后,我將提供指向文檔的直接鏈接。
在您的情況下,您應該使用trim()方法。 這只是從字符串的開頭和結尾去除空格。
<?php
$textarea = " Lorem ipsum dolor ";
$trimmed_textarea = trim($textarea); //this returns the $textarea string without whitespaces
echo $trimmed_textarea;
?>
如果您需要進一步的說明,您可以查看修剪功能的文檔。 修剪()
//在控制器中
$texts = "this is very very long text"; //you might retrieve from database
//最終使用
trim($texts);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.