1.strlen 獲取字串的長度
$str = 'abcdef';
echo strlen($str);
$str = ' ab cd ';
echo strlen($str);
2.stripslashes 引用斜槓
$str="wo hai shi \cong qian";
echo stripslashes($str);

3.stripos 查詢字串首次出現的位置(不區分大小寫)
echo stripos("You love php, I love php too!","PHP");
4.strip_tags 從字串中取出HTML和PHP標記
echo strip_tags("hello <b style='color:red'>shao nian</b>");

echo strip_tags("hello <p><b style='color:red'>shao nian</b></p>","<b>");

5.strchr 是strstr 查詢字串的首次出現
6.sha1 計算字串的sha1雜湊值
echo sha1('123456');

7.sha1 計算字串的 sha1 雜湊值
echo sha1('123456');

8. rtrim 刪除字串末端的空白字元(或者其他字元)
echo rtrim(' 123 ');
echo rtrim(' 123dd','d');
9. lcfirst 使一個字串的第一個字元小寫
$bar = 'HELLO WORLD!';
$bar = lcfirst($bar);
$bar = lcfirst(strtoupper($bar));
10. join 是implode的別名 將一個一維陣列的值轉化為字串
$arr=array(33,44,55);
$str=join(',',$arr);
echo $str;

var_dump(implode('hello', array()));

本作品採用《CC 協議》,轉載必須註明作者和本文連結
The sun is always behind the storm~