PHP 8.5.0 Alpha 4 available for testing

Voting

: five plus three?
(Example: nine)

The Note You're Voting On

divinity76 at gmail dot com
3 years ago
this is the fastest php7-implementation i can think of, it should be faster than javalc6 and Reinder's implementations, as this one doesn't create new strings (but theirs does)

<?php
if (! function_exists('str_ends_with')) {
function
str_ends_with(string $haystack, string $needle): bool
{
$needle_len = strlen($needle);
return (
$needle_len === 0 || 0 === substr_compare($haystack, $needle, - $needle_len));
}
}
?>

<< Back to user notes page

To Top