KennisbankExamencentrum
NL · NLNederlands (Nederland)
Taal kiezen13

CKTIS / PHP

strpos()

Geeft de eerste hoofdlettergevoelige bytepositie of false.

Versie: PHP 8.4; repository runtime, production runtime not attested

Syntax

strpos(string $haystack, string $needle, int $offset = 0): int|false

Geeft de eerste hoofdlettergevoelige bytepositie of false. Een treffer aan het begin is het gehele getal nul, dus test mislukking strikt. Een negatieve offset telt het zoekbegin vanaf het einde, buiten het bereik ontstaat ValueError.

Signatuur

strpos(string $haystack, string $needle, int $offset = 0): int|false

Uitvoer van het voorbeeld

[0,3,false,false]

Voorbeelden

<?php
$s="ab-ab"; echo json_encode([strpos($s,"ab"),strpos($s,"ab",-2),strpos($s,"AB"),strpos($s,"ab")===false]);

Resultaat

[0,3,false,false]

Bronnen