**獲取字符串的長度:** strlen()
```
strlen('Hello World');
```
**字符串翻轉:** strrev()
```
strrev('Hello World');
```
**查找一個字符串在另一個字符串中的位置:** strpos()
```
strpos('Hello World','World');
```
**字符串替換:** str_replace();
```
str_replace('World','list','Hello World');
```
**數字格式化**
```
$num = 4.30258;
第一種:利用php round方法對浮點數進行四舍五入
echo round($num, 2); //4.30
第二種:利用sprintf格式化字符串
$format_num = sprintf("%.2f", $num);
echo $format_num; //4.30
第三種:利用千位分組來格式化數字的函數number_format()
echo number_format($num, 2, ".", ""); //4.30
```
**全部轉換成小寫**
```
strtolower('Hello World');
```
**全部轉換成大寫**
```
strtoupper('Hello World');
```
**時間格式的字符串轉換成整型時間戳**
```
strtotime($str);
```
**去除不含$tags里標簽外的所有標簽**
```
strip_tags($str [,$tags]);
```
**編碼成json 格式的字符串**
```
json_encode($obj/$arr/$str...);
```
**解碼成對象,當$assoc=true 時 返回數組 而非對象**
```
json_decode($jsonstr [,$assoc=true]);
```
**將一維數組轉換為字符串**
```
implode($arr,$glue);
```
**字符串轉換為數組**
```
explode();
```
**字符串加密函**
```
sha1($str);
md5($str);
```
截取字符串$str的第一個字符截取長度3長度不填默認截取到最后參數為負數則倒數
```
substr($str,0,3);
```
**截取字符串 $str 中的第一個字符'a'后的字符串**
```
strstr($str,'a');
```
截取字符串 $str 中最后一一個字符'a'后的字符串
```
strrchr($str,'a');
```