string trim ( string $str [, string $charlist ] )
其中 $str 是要进行处理的字符串。 |
测试代码: |
[PHP] 纯文本查看 复制代码 <?php |
$text = "\t\thello\t"; |
echo $text; |
print " "; |
echo trim($text, "\t"); |
print " "; |
print "-------------- "; |
$text = " linux "; |
echo $text; |
echo trim($text, " "); |
print " "; |
print "-------------- "; |
$text = "\x0Bworld"; |
echo $text; |
echo $text; |
echo $text; |
echo $text; |
print " "; |
echo trim($text, "\x0B"); |
print " "; |
print "-------------- "; |
?> |
<?php
function _formatDir($dir) {
$dir = trim($dir);
if ($dir)
$dir = trim($dir, "\\/><").'/';
return $dir;
}
$mydir = '><home\><wwwroot/ ';
echo $mydir;
print "\n";
echo _formatDir($mydir);
print "\n";
?>
$ php trim.php
><home\><wwwroot/
home\><wwwroot/
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |