trim/ltrim/rtrim/ucfirst/ucwords例子!

trim/ltrim/rtrim/ucfirst/ucwords例子!

 

<?php
/**
 * QQ:5871029 Email:hel8@vip.qq.com
 * @copyright Horleun (c)2010
 * @author Horleun <Horleun@foxmail.com>
 */
$text=” .我的理解a1..\t  .\n”;
echo $text;
echo”<br/>”;
echo trim($text,” \n\t.”);

echo ltrim($text,” \n\t.”); //左侧去除
echo rtrim($text,” \n\t.”);  //去除右侧
echo”<br/>”;echo”<br/>”;

/*大小写转换*/
$a=”I love PHP!”;
echo strtolower($a);
echo”<br/>”;
echo strtoupper($a);

echo”<br/>”;echo”<br/>”;
//ucfirst
$a=”i want to change!”;
echo ucfirst($a); //首字母大写!
echo”<br/>”;
echo ucwords($a); //每个单词首字母大写!
?>

首尾空格删除和大小写转换的例子!

.我的理解a1.. .
我的理解a1我的理解a1.. . .我的理解a1

i love php!
I LOVE PHP!

I want to change!
I Want To Change!

留下回复