]>
jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blob - misc/strings.php
3 /** Splits up a string by a space
12 function split($str, $delimiter = " ") : Array
14 return explode($delimiter,$str);
20 * @param mixed $delimiter
23 function glue($array, $delimiter = " ")
26 foreach($array as $str)
30 $string .= $str.$delimiter;
32 return trim($string,$delimiter);
36 * Gets the relative path of the filename
37 * @param mixed $filename
40 function get_relative_path($filename)
42 $relativepath = split($filename, "/");
43 foreach($relativepath as &$tok)
45 $isFinal = ($tok == "html") ? 1 : 0;
50 $relativepath = glue($relativepath,"/");
55 * Returns a `nick` if the string was in the syntax:
60 function show_nick_only($str)
62 $x = strpos($str, "!");
64 $str = substr($str, 0, $x);
69 function how_long_ago($timestamp)
72 $diff = $now - strtotime($timestamp);
83 foreach ($units as $unit => $text) {
84 if ($diff < $unit) continue;
85 $numberOfUnits = floor($diff / $unit);
86 return $numberOfUnits.' '.$text.(($numberOfUnits>1)?'s':'').' ago';