-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils.inc.php
49 lines (44 loc) · 1.07 KB
/
utils.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
function form_select($name,$options,$selected = '',$params = '')
{
$return = '<select name="'.$name.'" id="'.$name.'"';
if(is_array($params))
{
foreach($params as $key=>$value)
{
$return.= ' '.$key.'="'.$value.'"';
}
}
else
{
$return.= $params;
}
$return.= '>';
foreach($options as $key=>$value)
{
$return.='<option value="'.$value.'"'.($selected != $value ? '' : ' selected="selected"').'>'.$key.'</option>';
}
return $return.'</select>';
}
function reformat($str) {
$pattern = array(
'/\*\*(.*?)\*\*/is',
'/__(.*?)__/is',
'/(http:\/\/\S*)/is',
'/(https:\/\/\S*)/is',
'/(ftp:\/\/\S*)/is',
'/(\S*?@\S*)/is',
);
$replace = array(
'<strong>$1</strong>',
'<u>$1</u>',
'<a href="$1">$1</a>',
'<a href="$1">$1</a>',
'<a href="$1">$1</a>',
'<a href="mailto:$1">$1</a>',
);
$str = preg_replace ($pattern, $replace, $str);
$str = nl2br($str);
return $str;
}
?>