strncmp 函數用于比較兩個字符串的前 n 個字符是否相等,其參數如下:
strncmp
str1
str2
n
示例:
$str1 = "Hello World"; $str2 = "Hello PHP"; $result = strncmp($str1, $str2, 5); // 比較前 5 個字符 echo $result; // 輸出 0,表示相等