forked from stz2012/epgrec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reclib.php
43 lines (34 loc) · 1.17 KB
/
reclib.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
<?php
// ライブラリ
function toTimestamp( $string ) {
sscanf( $string, "%4d-%2d-%2d %2d:%2d:%2d", $y, $mon, $day, $h, $min, $s );
return mktime( $h, $min, $s, $mon, $day, $y );
}
function toDatetime( $timestamp ) {
return date("Y-m-d H:i:s", $timestamp);
}
function jdialog( $message, $url = "index.php" ) {
header( "Content-Type: text/html;charset=utf-8" );
exit( "<script type=\"text/javascript\">\n" .
"<!--\n".
"alert(\"". $message . "\");\n".
"window.open(\"".$url."\",\"_self\");".
"// -->\n</script>" );
}
// マルチバイトstr_replace
function mb_str_replace($search, $replace, $target, $encoding = "UTF-8" ) {
$notArray = !is_array($target) ? TRUE : FALSE;
$target = $notArray ? array($target) : $target;
$search_len = mb_strlen($search, $encoding);
$replace_len = mb_strlen($replace, $encoding);
foreach ($target as $i => $tar) {
$offset = mb_strpos($tar, $search);
while ($offset !== FALSE){
$tar = mb_substr($tar, 0, $offset).$replace.mb_substr($tar, $offset + $search_len);
$offset = mb_strpos($tar, $search, $offset + $replace_len);
}
$target[$i] = $tar;
}
return $notArray ? $target[0] : $target;
}
?>