PHP strncasecmp() Fungsi
Contoh
Bandingkan dua string (tidak peka huruf besar/kecil):
<?php
echo strncasecmp("Hello world!","hello earth!",6);
?>
Definisi dan Penggunaan
Fungsi strncasecmp() membandingkan dua string.
Catatan: strncasecmp() adalah binary-safe dan case-insensitive.
Tip: Fungsi ini mirip dengan fungsi strcasecmp() , kecuali bahwa strcasecmp() tidak memiliki parameter panjang.
Sintaksis
strncasecmp(string1,string2,length)
Nilai Parameter
Parameter | Description |
---|---|
string1 | Required. Specifies the first string to compare |
string2 | Required. Specifies the second string to compare |
length | Required. Specify the number of characters from each string to be used in the comparison |
Detail Teknis
Nilai Kembali: | Fungsi ini mengembalikan:
|
---|---|
Versi PHP: | 4.0.2+ |
Lebih Banyak Contoh
Contoh
Bandingkan dua string (case-insensitive = Hello dan hELLo akan menghasilkan output yang sama):
<?php
echo strncasecmp("Hello","Hello",6);
echo "<br>";
echo strncasecmp("Hello","hELLo",6);
?>
Referensi String PHP