-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelper.php
30 lines (26 loc) · 838 Bytes
/
helper.php
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
26
27
28
29
30
<?php
if (!function_exists('str_between')) {
function str_between(string $string, string $start, string $end): string
{
return strstr(ltrim(strstr($string, $start), $start), $end, true);
}
}
if (!function_exists('str_starts_with')) {
function str_starts_with(string $string, string $needle): bool
{
return substr($string, 0, strlen($needle)) === $needle;
}
}
if (!function_exists('str_ends_with')) {
function str_ends_with(string $string, string $needle): bool
{
$length = strlen($needle);
return !$length || substr($string, -$length) === $needle;
}
}
if (!function_exists('str_is_between')) {
function str_is_between(string $string, string $start, string $end): bool
{
return str_starts_with($string, $start) && str_ends_with($string, $end);
}
}