- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
25 lines (20 loc) · 521 Bytes
/
functions.php
File metadata and controls
25 lines (20 loc) · 521 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
if (!function_exists('str_starts_with')) {
function str_starts_with($haystack, $needle)
{
return 0 === strncmp($haystack, $needle, \strlen($needle));
}
}
if (!function_exists('str_ends_with')) {
function str_ends_with($haystack, $needle)
{
if ('' === $needle || $needle === $haystack) {
return true;
}
if ('' === $haystack) {
return false;
}
$needleLength = \strlen($needle);
return $needleLength <= \strlen($haystack) && 0 === substr_compare($haystack, $needle, -$needleLength);
}
}