]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blobdiff - misc/strings.php
Rather large update, please see commit notes
[irc/unrealircd/unrealircd-webpanel.git] / misc / strings.php
index 4a1fc905328f9e38ef56f2591b1a4f97692b12a1..199c0f15fe8db5289697f4702d92c4450633e257 100644 (file)
@@ -14,6 +14,12 @@ function split($str, $delimiter = " ") : Array
        return explode($delimiter,$str);
 }
 
+/**
+ * 
+ * @param mixed $array
+ * @param mixed $delimiter
+ * @return string
+ */
 function glue($array, $delimiter = " ")
 {
        $string = "";
@@ -26,6 +32,11 @@ function glue($array, $delimiter = " ")
        return trim($string,$delimiter);
 }
 
+/**
+ * Gets the relative path of the filename
+ * @param mixed $filename
+ * @return string
+ */
 function get_relative_path($filename)
 {
     $relativepath = split($filename, "/");
@@ -39,3 +50,17 @@ function get_relative_path($filename)
     $relativepath = glue($relativepath,"/");
     return $relativepath;
 }
+
+/**
+ * Returns a `nick` if the string was in the syntax:
+ * nick!ident@host
+ * @param mixed $str
+ * @return mixed
+ */
+function show_nick_only($str)
+{
+       $x = strpos($str, "!");
+       if ($x !== false)
+               $str = substr($str, 0, $x);
+       return $str;
+}