CKTIS / PHP
strncmp()
Confronta al massimo length byte distinguendo le maiuscole.
Versione: PHP 8.4; repository runtime, production runtime not attested
Sintassi
strncmp(string $string1, string $string2, int $length): intConfronta al massimo length byte distinguendo le maiuscole. L’uguaglianza dei primi N byte non implica stringhe identiche. Se differiscono usa il segno. Lunghezza zero dà zero e una negativa genera ValueError.
Firma
strncmp(string $string1, string $string2, int $length): int
Output dell’esempio
[0,true,true]
Esempi
<?php
echo json_encode([strncmp("xyA","xyB",2),strncmp("xyA","xyB",3)<0,strncmp("A","a",1)<0]);
Risultato
[0,true,true]