|
Server : Apache/2.2.2 (Fedora) System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686 User : apache ( 48) PHP Version : 5.2.9 Disable Function : NONE Directory : /home/pathumthani_integration/integration/application/industry/function/ |
Upload File : |
<?php
function searchReplace($key="", $data = ""){
//return 'test';
//exit();
$arrS = explode(" ",$key);
$search = array();
$replace = array();
if(is_array($arrS)){
foreach($arrS as $value){
$replace[] = '<span style="background:#FFCC99;">'.$value.'</span>';
}
}else{
$replace[] = '<span style="background:#FFCC99;">'.$key.'</span>';
}
$search[] = $key;
$data_replace = str_replace($search, $replace, $data);
return $data_replace;
//return 'test';
}
function dateFormat($value,$type){
if($type=="engthai"){
$day = explode("-",$value);
$date = $day[2].'-'.$day[1].'-'.($day[0]+543);
}else if($type=="thaieng"){
$day = explode("-",$value);
$date = ($day[2]-543).'-'.$day[1].'-'.$day[0];
}else if($type=="thaidot"){
$Month = array("", "Á.¤.", "¡.¾.", "ÁÕ.¤.", "àÁ.Â.", "¾.¤.", "ÁÔ.Â.", "¡.¤.", "Ê.¤.", "¡.Â.", "µ.¤.", "¾.Â.", "¸.¤.");
$day = explode("-",$value);
$Y = $day[0];
$m = $day[1];
if($m<10){
$m = str_replace("0","",$m);
}
$d = $day[2]*1;
$date = $d.' '.$Month[$m].' '.($Y+543);
}else if($type==""){
$date = explode("-",$value);
}
return $date;
}
function keytoMySqlDate($d)
{
$d2 = explode("/",$d);
if(count($d2) < 3)
{
return '';
}
$d3[0] = $d2[2]-543;
$d3[1] = $d2[1];
$d3[2] = $d2[0];
return implode("-",$d3);
}
function mysqlToKeyDate($d,$format='')
{
$d2 = explode("-",$d);
if(count($d2) < 3 || $d=='0000-00-00')
{
return '';
}
$d3[1] = $d2[2];
$d3[2] = $d2[1];
$d3[3] = $d2[0]+543;
$d4;
if($format=='thaidot')
{
$d4 = implode("/",$d3);
$d4 = dateFormat($d4,$format);
}
else
{
$d4 = implode("/",$d3);
}
return $d4;
}
?>