diff options
author | Arthur <arthur@hoa.ro> | 2016-05-14 11:09:03 +0200 |
---|---|---|
committer | Arthur <arthur@hoa.ro> | 2016-05-14 11:09:03 +0200 |
commit | 765391cb376500a8372aedd426dd4bfbe04ee8ec (patch) | |
tree | cc9bb6efaf3207a0334d362d75a6f1d1fe297252 /application/Utils.php | |
parent | 19f53aa18cfa2c78ab798153c31c6e4b23b3c4c9 (diff) | |
parent | 5046bcb6ab324a6b52669b2b76a41665022f653a (diff) | |
download | Shaarli-765391cb376500a8372aedd426dd4bfbe04ee8ec.tar.gz Shaarli-765391cb376500a8372aedd426dd4bfbe04ee8ec.tar.zst Shaarli-765391cb376500a8372aedd426dd4bfbe04ee8ec.zip |
Merge pull request #559 from ArthurHoaro/startsEndWithCase
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); |