PHP strncmp() Functie
❮ Referentie voor PHP-tekenreeksen
Voorbeeld
Vergelijk twee strings (hoofdlettergevoelig):
<?php
echo strncmp("Hello world!","Hello earth!",6);
?>
Definitie en gebruik
De functie strncmp() vergelijkt twee strings.
Opmerking: De strncmp() is binair veilig en hoofdlettergevoelig.
Tip: Deze functie lijkt op de functie strcmp() , behalve dat strcmp() de parameter length niet heeft.
Syntaxis
strncmp(string1,string2,length)
Parameterwaarden
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 |
Technische details
Winstwaarde: | Deze functie retourneert:
|
---|---|
PHP-versie: | 4+ |
Meer voorbeelden
Voorbeeld
Vergelijk twee strings (hoofdlettergevoelig = Hallo en hallo geven niet hetzelfde weer):
<?php
echo strncmp("Hello","Hello",6);
echo "<br>";
echo strncmp("Hello","hELLo",6);
?>
❮ Referentie voor PHP-tekenreeksen