server/src/app/Libraries/Utils.php
changeset 339 766af1228b05
parent 329 0a2c2ad49d75
child 386 c731ab9b934d
--- a/server/src/app/Libraries/Utils.php	Sun Oct 16 22:23:31 2016 +0530
+++ b/server/src/app/Libraries/Utils.php	Sun Oct 16 23:19:57 2016 +0530
@@ -134,4 +134,26 @@
         return new Graph($graph1->getUri(), $merged, 'php');
     }
 
+    /**
+     * From http://stackoverflow.com/a/834355
+     */
+    public static function startsWith($haystack, $needle)
+    {
+        $length = strlen($needle);
+        return (substr($haystack, 0, $length) === $needle);
+    }
+
+    /**
+     * From http://stackoverflow.com/a/834355
+     */
+    public static function endsWith($haystack, $needle)
+    {
+        $length = strlen($needle);
+        if ($length == 0) {
+            return true;
+        }
+
+        return (substr($haystack, -$length) === $needle);
+    }
+
 }