note 126551 added to function.str-ends-with

From: Date: Mon, 01 Nov 2021 15:49:29 +0000
Subject: note 126551 added to function.str-ends-with
Groups: php.notes 
Request: Send a blank email to php-notes+get-217134@lists.php.net to get a copy of this message
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)); } } ?> ---- Server IP: 45.112.84.4 Probable Submitter: 45.112.85.242 (proxied: 81.166.125.50) ---- Manual Page -- https://php.net/manual/en/function.str-ends-with.php Edit -- https://main.php.net/note/edit/126551 Del: integrated -- https://main.php.net/note/delete/126551/integrated Del: useless -- https://main.php.net/note/delete/126551/useless Del: bad code -- https://main.php.net/note/delete/126551/bad+code Del: spam -- https://main.php.net/note/delete/126551/spam Del: non-english -- https://main.php.net/note/delete/126551/non-english Del: in docs -- https://main.php.net/note/delete/126551/in+docs Del: other reasons-- https://main.php.net/note/delete/126551 Reject -- https://main.php.net/note/reject/126551 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#217134) next »