CKTIS / PHP
str_ends_with()
Test a case-sensitive byte suffix without extracting it.
Version: PHP 8.4; repository runtime, production runtime not attested
Syntax
str_ends_with(string $haystack, string $needle): boolTest a case-sensitive byte suffix without extracting it. A longer needle cannot fit and an empty needle always matches. For a case-insensitive file extension, apply an explicit normalization policy before this exact check.
Signature
str_ends_with(string $haystack, string $needle): bool
Example output
[true,false,false,true]
Examples
<?php
echo json_encode([str_ends_with("note.txt",".txt"),str_ends_with("note.TXT",".txt"),str_ends_with("x","xx"),str_ends_with("x","")]);
Result
[true,false,false,true]