]>
Commit | Line | Data |
---|---|---|
fe2a6f27 VP |
1 | <?php |
2 | ||
3 | /** Splits up a string by a space | |
4 | * (chr 32) | |
5 | * | |
6 | * Syntax: | |
7 | * split($string) | |
8 | * | |
9 | * Returns: | |
10 | * array $tokens | |
11 | */ | |
12 | function split($str, $delimiter = " ") : Array | |
13 | { | |
14 | return explode($delimiter,$str); | |
15 | } | |
16 | ||
33f512fa VP |
17 | /** |
18 | * | |
19 | * @param mixed $array | |
20 | * @param mixed $delimiter | |
21 | * @return string | |
22 | */ | |
fe2a6f27 VP |
23 | function glue($array, $delimiter = " ") |
24 | { | |
25 | $string = ""; | |
26 | foreach($array as $str) | |
27 | { | |
28 | if (!$str) | |
29 | continue; | |
30 | $string .= $str.$delimiter; | |
31 | } | |
32 | return trim($string,$delimiter); | |
33 | } | |
34 | ||
33f512fa VP |
35 | /** |
36 | * Gets the relative path of the filename | |
37 | * @param mixed $filename | |
38 | * @return string | |
39 | */ | |
fe2a6f27 VP |
40 | function get_relative_path($filename) |
41 | { | |
42 | $relativepath = split($filename, "/"); | |
43 | foreach($relativepath as &$tok) | |
44 | { | |
45 | $isFinal = ($tok == "html") ? 1 : 0; | |
46 | $tok = NULL; | |
47 | if ($isFinal) | |
48 | break; | |
49 | } | |
50 | $relativepath = glue($relativepath,"/"); | |
51 | return $relativepath; | |
62d4ea03 | 52 | } |
33f512fa VP |
53 | |
54 | /** | |
55 | * Returns a `nick` if the string was in the syntax: | |
56 | * nick!ident@host | |
57 | * @param mixed $str | |
58 | * @return mixed | |
59 | */ | |
60 | function show_nick_only($str) | |
61 | { | |
62 | $x = strpos($str, "!"); | |
63 | if ($x !== false) | |
64 | $str = substr($str, 0, $x); | |
65 | return $str; | |
66 | } |