note 128096 added to function.str-starts-with
| From: | atesin*gmail at main dot php dot net | Date: | Sat, 07 Jan 2023 18:14:08 +0000 |
| Subject: | note 128096 added to function.str-starts-with | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-220049@lists.php.net to get a copy of this message | ||
seems everybody forgot php4+ equivalent ... simple, light and readable
<?php
str_startswith($haystack, $needle)
{
return (strpos($haystack, $needle) === 0);
}
?>
note if strpos() doesn't find the needle will return FALSE, but if it finds at start will
return index 0... that is why "==="... it states strpos() is binary safe also
check for function existence according other comments say, or write inline because is short
----
Server IP: 45.112.84.4
Probable Submitter: 45.91.158.213 (proxied: 181.43.104.133)
----
Manual Page -- https://php.net/manual/en/function.str-starts-with.php
Edit -- https://main.php.net/note/edit/128096
Del: integrated -- https://main.php.net/note/delete/128096/integrated
Del: useless -- https://main.php.net/note/delete/128096/useless
Del: bad code -- https://main.php.net/note/delete/128096/bad+code
Del: spam -- https://main.php.net/note/delete/128096/spam
Del: non-english -- https://main.php.net/note/delete/128096/non-english
Del: in docs -- https://main.php.net/note/delete/128096/in+docs
Del: other reasons-- https://main.php.net/note/delete/128096
Reject -- https://main.php.net/note/reject/128096
Search -- https://main.php.net/manage/user-notes.php