Geen cache-versie.

Caching uitgeschakeld. Standaardinstelling voor deze pagina:ingeschakeld (code LNG204)
Als het scherm te langzaam is, kunt u de gebruikersmodus uitschakelen om de cacheversie te bekijken.

Rechercher une fonction PHP

substr_compare

(PHP 5, PHP 7)

substr_compareBinary safe comparison of two strings from an offset, up to length characters

Description

substr_compare ( string $main_str , string $str , int $offset [, int $length [, bool $case_insensitivity = FALSE ]] ) : int

substr_compare() compares main_str from position offset with str up to length characters.

Eerste pagina van Manuel PHP  Inhoudsopgave Haut

Parameters

main_str

The main string being compared.

str

The secondary string being compared.

offset

The start position for the comparison. If negative, it starts counting from the end of the string.

length

The length of the comparison. The default value is the largest of the length of the str compared to the length of main_str minus the offset.

case_insensitivity

If case_insensitivity is TRUE, comparison is case insensitive.

Eerste pagina van Manuel PHP  Inhoudsopgave Haut

Return Values

Returns < 0 if main_str from position offset is less than str, > 0 if it is greater than str, and 0 if they are equal. If offset is equal to (prior to PHP 7.2.18, 7.3.5) or greater than the length of main_str, or the length is set and is less than 0, (or, prior to PHP 5.5.11, less than 1) substr_compare() prints a warning and returns FALSE.

Eerste pagina van Manuel PHP  Inhoudsopgave Haut

Changelog

Version Description
7.2.18, 7.3.5 offset may now be equal to the length of main_str.
5.5.11 length may now be 0.
5.1.0 Added the possibility to use a negative offset.

Eerste pagina van Manuel PHP  Inhoudsopgave Haut

Examples

Example #1 A substr_compare() example

<?php
echo substr_compare("abcde""bc"12); // 0
echo substr_compare("abcde""de", -22); // 0
echo substr_compare("abcde""bcg"12); // 0
echo substr_compare("abcde""BC"12true); // 0
echo substr_compare("abcde""bc"13); // 1
echo substr_compare("abcde""cd"12); // -1
echo substr_compare("abcde""abc"51); // warning
?>

Eerste pagina van Manuel PHP  Inhoudsopgave Haut

See Also

  • strncmp() - Binary safe string comparison of the first n characters

Zoek een PHP-functie

Vertaling niet beschikbaar

De PHP-handleiding is nog niet in het Nederlands vertaald, dus het scherm is in het Engels. Als u wilt, kunt u het ook in het Frans of in het Duits raadplegen.

Als je de moed voelt, kun je je vertaling aanbieden ;-)

Nederlandse vertaling

U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.

Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.

Bij voorbaat dank.

Document heeft de 30/01/2003 gemaakt, de laatste keer de 26/10/2018 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/php-rf-function.substr-compare.html

De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.

Referenties

  1. Bekijk - html-document Taal van het document:fr Manuel PHP : http://php.net

Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.

Inhoudsopgave Haut