aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/Utils.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2016-05-10 23:31:41 +0200
committerArthurHoaro <arthur@hoa.ro>2016-05-10 23:31:41 +0200
commit5046bcb6ab324a6b52669b2b76a41665022f653a (patch)
tree84a2c144ef7d9eb0a585d2c8e1bfe63311f979a3 /application/Utils.php
parentd95533778d86bb6c6de3b14a9da35e6d6e6428bd (diff)
downloadShaarli-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.php16
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 */
45function startsWith($haystack, $needle, $case=true) 51function 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 */
56function endsWith($haystack, $needle, $case=true) 68function 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);