最新php中四个去除字符串中空字符的函数
以下是三零网为大家整理的最新php中四个去除字符串中空字符的函数的文章,希望大家能够喜欢!
php中包含四个可以去除字符串空格的函数:
trim() – 去除字符串两端的空字符
ltrim() – 去除字符串前端的空字符
rtrim() – 去除字符串末尾的空字符
chop() –同rtrim().
<?php
$text = "\t \t *.com!\t \t ";
$leftTrimmed = ltrim($text);
$rightTrimmed = rtrim($text);
$bothTrimmed = trim($text);
print("leftTrimmed = ($leftTrimmed)\n");
print("rightTrimmed = ($rightTrimmed)\n");
print("bothTrimmed = ($bothTrimmed)\n");
?>
|
|