从开始的PHP中删除多余的空格?
如果要从一开始就删除多余的空格,请ltrim()在PHP中使用。假设以下是我们的变量-
$value=" Hello, welcome to PHP Tutorial ";
我们想要左侧没有空白的输出-
Hello, welcome to PHP Tutorial
示例
<!DOCTYPE html> <html> <body> <?php $value=" Hello, welcome to PHP Tutorial "; print_r( "The actual value is=".$value."<br>"); echo "The actual length is=",strlen($value)."<br>"; $modifiedValue=ltrim($value); echo "After removing extra whitespace from beginning=",strlen($modifiedValue)."<br>"; echo "The result is=".$modifiedValue; ?> </body> </html>
输出结果
这将产生以下输出
The actual value is= Hello, welcome to PHP Tutorial The actual length is=34 After removing extra whitespace from beginning=32 The result is=Hello, welcome to PHP Tutorial
热门推荐
10 病人祝福语老师寄语简短
11 新娘生孩子祝福语简短
12 婆婆66岁祝福语简短
13 今天孩子高考祝福语简短
14 送彩票生日祝福语简短
15 分别祝福语简短情话英文
16 画室揭牌仪式祝福语简短
17 女友妈妈生日祝福语简短
18 离别赠言离职祝福语简短