diff options
author | ArthurHoaro <arthur@hoa.ro> | 2016-05-10 23:31:41 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2016-05-10 23:31:41 +0200 |
commit | 5046bcb6ab324a6b52669b2b76a41665022f653a (patch) | |
tree | 84a2c144ef7d9eb0a585d2c8e1bfe63311f979a3 /application/Utils.php | |
parent | d95533778d86bb6c6de3b14a9da35e6d6e6428bd (diff) | |
download | Shaarli-5046bcb6ab324a6b52669b2b76a41665022f653a.tar.gz Shaarli-5046bcb6ab324a6b52669b2b76a41665022f653a.tar.zst Shaarli-5046bcb6ab324a6b52669b2b76a41665022f653a.zip |
Fix startsWith and endsWith case
Diffstat (limited to 'application/Utils.php')
-rw-r--r-- | application/Utils.php | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/application/Utils.php b/application/Utils.php index 5b8ca508..da521cce 100644 --- a/application/Utils.php +++ b/application/Utils.php | |||
@@ -41,8 +41,14 @@ function smallHash($text) | |||
41 | 41 | ||
42 | /** | 42 | /** |
43 | * Tells if a string start with a substring | 43 | * Tells if a string start with a substring |
44 | * | ||
45 | * @param string $haystack Given string. | ||
46 | * @param string $needle String to search at the beginning of $haystack. | ||
47 | * @param bool $case Case sensitive. | ||
48 | * | ||
49 | * @return bool True if $haystack starts with $needle. | ||
44 | */ | 50 | */ |
45 | function startsWith($haystack, $needle, $case=true) | 51 | function startsWith($haystack, $needle, $case = true) |
46 | { | 52 | { |
47 | if ($case) { | 53 | if ($case) { |
48 | return (strcmp(substr($haystack, 0, strlen($needle)), $needle) === 0); | 54 | return (strcmp(substr($haystack, 0, strlen($needle)), $needle) === 0); |
@@ -52,8 +58,14 @@ function startsWith($haystack, $needle, $case=true) | |||
52 | 58 | ||
53 | /** | 59 | /** |
54 | * Tells if a string ends with a substring | 60 | * Tells if a string ends with a substring |
61 | * | ||
62 | * @param string $haystack Given string. | ||
63 | * @param string $needle String to search at the end of $haystack. | ||
64 | * @param bool $case Case sensitive. | ||
65 | * | ||
66 | * @return bool True if $haystack ends with $needle. | ||
55 | */ | 67 | */ |
56 | function endsWith($haystack, $needle, $case=true) | 68 | function endsWith($haystack, $needle, $case = true) |
57 | { | 69 | { |
58 | if ($case) { | 70 | if ($case) { |
59 | return (strcmp(substr($haystack, strlen($haystack) - strlen($needle)), $needle) === 0); | 71 | return (strcmp(substr($haystack, strlen($haystack) - strlen($needle)), $needle) === 0); |