php一些常用的操作(如求長度,切割等等)

php 求長度(中英文適用)

$length = mb_strlen(trim($introductionOpen),'utf-8')

 

php 切割字符串長度(中英文適用)

$strString =  mb_substr($introductionOpen, 0, 80, 'UTF-8');

 

php 切割字符串最後一個字符(中英文適用)

$currentCity =mb_substr($currentCity, -1, 1, 'UTF-8');

 

php 切割字符串除了最後一個字符,取之前的字符串(中英文適用)

$currentCity = mb_substr($currentCity, 0, -1, 'UTF-8');

 

 

php 切割數組(去掉數組最後一個)

$argumentArr = array_slice($arg_argumentArr, 0, -1);

 

 

php 切割數組(去掉數組第一個)

$fieldNames = array_slice($fieldNames,1);

 

 

php foreach(鍵值形式)

foreach ($movie as $key => $value)



php 設置utf-8


header("Content-Type: text/html; charset=utf-8");



php將數組拼接成以‘,’隔開的字符串 如 lastName,email,phone


 $fields .=  implode(' ,', $fieldNames) . ' )';


 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章