Rev | Line | |
---|
[44] | 1 | <?php
|
---|
| 2 | function begtoend($htmltag){
|
---|
| 3 | return preg_replace('/<([A-Za-z]+)>/','</$1>',$htmltag);
|
---|
| 4 | }
|
---|
| 5 | function replace_pcre_array($text,$array){
|
---|
| 6 | $pattern = array_keys($array);
|
---|
| 7 | $replace = array_values($array);
|
---|
| 8 | $text = preg_replace($pattern,$replace,$text);
|
---|
| 9 | return $text;
|
---|
| 10 | }
|
---|
| 11 | function ezDate($d) {
|
---|
| 12 | $ts = time() - $d;
|
---|
| 13 |
|
---|
| 14 | if($ts>31536000) $val = round($ts/31536000,0).' year';
|
---|
| 15 | else if($ts>2419200) $val = round($ts/2419200,0).' month';
|
---|
| 16 | else if($ts>604800) $val = round($ts/604800,0).' week';
|
---|
| 17 | else if($ts>86400) $val = round($ts/86400,0).' day';
|
---|
| 18 | else if($ts>3600) $val = round($ts/3600,0).' hour';
|
---|
| 19 | else if($ts>60) $val = round($ts/60,0).' minute';
|
---|
| 20 | else $val = $ts.' second';
|
---|
| 21 |
|
---|
| 22 | if($val>1) $val .= 's';
|
---|
| 23 | return $val;
|
---|
| 24 | }
|
---|
| 25 | ?>
|
---|
Note:
See
TracBrowser
for help on using the repository browser.