note 129623 added to function.str-starts-with
| From: | contact@needlecode.com | Date: | Mon, 01 Jul 2024 20:00:30 +0000 |
| Subject: | note 129623 added to function.str-starts-with | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221400@lists.php.net to get a copy of this message | ||
Polyfill codes of str_starts_with by MAMEDUL ISLAM from Bangladesh.
<?php
if( !function_exists('str_starts_with') ){
/**
* str_starts_with â Checks if a string starts with a given substring
*
* @param string $haystack - The string to search in.
* @param string $needle - The substring to search for in the haystack.
* @return bool - Returns true if haystack begins with needle, false otherwise.
*/
function str_starts_with($haystack, $needle){
if( !is_scalar($haystack) || !is_scalar($needle) ){
return false;
}
if( strlen(strval($haystack)) < strlen(strval($needle)) ){
return false;
}
return substr( strval($haystack), 0, strlen(strval($needle)) ) == strval($needle);
}
}
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.137 (proxied: 37.111.222.41)
----
Manual Page -- https://php.net/manual/en/function.str-starts-with.php
Edit -- https://main.php.net/note/edit/129623
Del: integrated -- https://main.php.net/note/delete/129623/integrated
Del: useless -- https://main.php.net/note/delete/129623/useless
Del: bad code -- https://main.php.net/note/delete/129623/bad+code
Del: spam -- https://main.php.net/note/delete/129623/spam
Del: non-english -- https://main.php.net/note/delete/129623/non-english
Del: in docs -- https://main.php.net/note/delete/129623/in+docs
Del: other reasons-- https://main.php.net/note/delete/129623
Reject -- https://main.php.net/note/reject/129623
Search -- https://main.php.net/manage/user-notes.php