PHP指定字符串长度截取
在取数据的时候可以控制长度,加密算法也可以用到。 function sysSubStr($pass,$Length) { if (strlen($pass) <= $Length ) { return $pass; } else { $I = 0; while ($I < $Length) { $StringTMP = substr($pass,$I,1); if ( ord($StringTMP) >=224 ) { $StringTMP = substr($pass,$I,3); $I = $I + 3; } elseif( ord($StringTMP) >=192 ) { $StringTMP = substr($pass,$I,2); $I = $I + 2; } else { $I = $I + 1; } $StringLast[] = $StringTMP; } $StringLast = implode("",$StringLast); return $StringLast; } }