$conn_string = "host=localhost port=5432 dbname=myDB user=postgres password=pgadmin";
$conn = pg_connect($conn_string);
<?php function RP($rupiah){return number_format($rupiah,"2",",",".");}?>
<?php
function WKT($sekarang){
$tanggal = substr($sekarang,8,2)+0;
$bulan = substr($sekarang,5,2);
$tahun = substr($sekarang,0,4);
$judul_bln=array(1=> "Januari", "Februari", "Maret", "April", "Mei","Juni", "Juli", "Agustus", "September","Oktober", "November", "Desember");
$wk=$tanggal." ".$judul_bln[(int)$bulan]." ".$tahun;
return $wk;
}
?>
<?php
function WKTP($sekarang){
$tanggal = substr($sekarang,8,2)+0;
$bulan = substr($sekarang,5,2);
$tahun = substr($sekarang,2,2);
$judul_bln=array(1=> "Jan", "Feb", "Mar", "Apr", "Mei","Jun", "Jul", "Agu", "Sep","Okt", "Nov", "Des");
$wk=$tanggal." ".$judul_bln[(int)$bulan]."'".$tahun;
return $wk;
}
?>
<?php
function BAL($tanggal){
$arr=split(" ",$tanggal);
if($arr[1]=="Januari"){$bul="01";}
else if($arr[1]=="Februari"){$bul="02";}
else if($arr[1]=="Maret"){$bul="03";}
else if($arr[1]=="April"){$bul="04";}
else if($arr[1]=="Mei"){$bul="05";}
else if($arr[1]=="Juni"){$bul="06";}
else if($arr[1]=="Juli"){$bul="07";}
else if($arr[1]=="Agustus"){$bul="08";}
else if($arr[1]=="September"){$bul="09";}
else if($arr[1]=="Oktober"){$bul="10";}
else if($arr[1]=="November"){$bul="11";}
else if($arr[1]=="Nopember"){$bul="11";}
else if($arr[1]=="Desember"){$bul="12";}
return "$arr[2]-$bul-$arr[0]";
}
?>
<?php
function BALP($tanggal){
$arr=split(" ",$tanggal);
if($arr[1]=="Jan"){$bul="01";}
else if($arr[1]=="Feb"){$bul="02";}
else if($arr[1]=="Mar"){$bul="03";}
else if($arr[1]=="Apr"){$bul="04";}
else if($arr[1]=="Mei"){$bul="05";}
else if($arr[1]=="Jun"){$bul="06";}
else if($arr[1]=="Jul"){$bul="07";}
else if($arr[1]=="Agu"){$bul="08";}
else if($arr[1]=="Sep"){$bul="09";}
else if($arr[1]=="Okt"){$bul="10";}
else if($arr[1]=="Nov"){$bul="11";}
else if($arr[1]=="Nop"){$bul="11";}
else if($arr[1]=="Des"){$bul="12";}
return "$arr[2]-$bul-$arr[0]";
}
?>
<?php
function process($conn,$sql){
$result = pg_query($conn, $sql );
//pg_close($conn);
return $s;
}
function getJum($conn,$sql){
//echo $sql;
$result = pg_query($conn,$sql);
$jum
= pg_num_rows($result);
// pg_close($conn);
return $jum;
}
function getField($conn,$sql){
//echo $sql;
$result = pg_query($conn,$sql);
$row = pg_fetch_assoc($result);
//
pg_close($conn);
return $row;
}
function getData($conn,$sql){
$result = pg_query($conn,$sql);
while ($row = pg_fetch_assoc($result)){
$data[] =$row;// array( );
}
return $data;
}
function getAdmin($conn,$kode){
$field="nama";
$sql="SELECT $field FROM akademik.latihan where id='$kode'";
$result = pg_query($conn,$sql);
$row = pg_fetch_assoc($result);
$x=$row["nama"];
pg_close($conn);
return $x;
}
?>
<?php
function getHit($kal,$kalimat){
$ar=explode(" ",$kalimat);
$ada=0;
for($i=0;$i<count($ar);$i++){
if($kal==$ar[$i]){$ada++;}
}//for
return $ada;
}
?>
<?php
function swap(&$arr, $a, $b) {
$tmp = $arr[$a];
$arr[$a] = $arr[$b];
$arr[$b] = $tmp;
}
?>
<?php
function getNorm($judul){
require_once __DIR__ . '/vendor/autoload.php';
$initos = new \Sastrawi\Stemmer\StemmerFactory();
$bikinos = $initos->createStemmer();
$stemming=$bikinos->stem($judul);
$stemmingnew=strtolower($stemming);
$ak=getStopNumber();
$ar=getStopWords();
$wordStop=$stemmingnew;
for($i=0;$i<count($ar);$i++){
$wordStop =str_replace($ar[$i]." ","", $wordStop);
}
for($i=0;$i<count($ak);$i++){
$wordStop =str_replace($ak[$i],"", $wordStop);
}
$juduluji=str_replace(" "," ", $wordStop);
//=====================================================
$stemming=$juduluji;
$arAsli=explode(".",$stemming);
$jumk=count($arAsli);
$AR=explode(" ",$stemming);
$AR=array_unique($AR);
$m=0;
$gab="";
for($i=0;$i<count($AR);$i++){
if(strlen($AR[$i])>1){
$arUnix[$m]=$AR[$i];
$gab.=$AR[$i]." ";
$m++;
}
}
return trim($gab);
}
function getStopWords()
{
return array(
'yang', 'untuk', 'pada', 'ke', 'para', 'namun', 'menurut', 'antara', 'dia', 'dua',
'ia', 'seperti', 'jika', 'jika', 'sehingga', 'kembali', 'dan', 'tidak', 'ini', 'karena',
'kepada', 'oleh', 'saat', 'harus', 'sementara', 'setelah', 'belum', 'kami', 'sekitar',
'bagi', 'serta', 'di', 'dari', 'telah', 'sebagai', 'masih', 'hal', 'ketika', 'adalah',
'itu', 'dalam', 'bisa', 'bahwa', 'atau', 'hanya', 'kita', 'dengan', 'akan', 'juga',
'ada', 'mereka', 'sudah', 'saya', 'terhadap', 'secara', 'agar', 'lain', 'anda',
'begitu', 'mengapa', 'kenapa', 'yaitu', 'yakni', 'daripada', 'itulah', 'lagi', 'maka',
'tentang', 'demi', 'dimana', 'kemana', 'pula', 'sambil', 'sebelum', 'sesudah', 'supaya',
'guna', 'kah', 'pun', 'sampai', 'sedangkan', 'selagi', 'sementara', 'tetapi', 'apakah',
'kecuali', 'sebab', 'selain', 'seolah', 'seraya', 'seterusnya', 'tanpa', 'agak', 'boleh',
'dapat', 'dsb', 'dst', 'dll', 'dahulu', 'dulunya', 'anu', 'demikian', 'tapi', 'ingin',
'juga', 'nggak', 'mari', 'nanti', 'melainkan', 'oh', 'ok', 'seharusnya', 'sebetulnya',
'setiap', 'setidaknya', 'sesuatu', 'pasti', 'saja', 'toh', 'ya', 'walau', 'tolong',
'tentu', 'amat', 'apalagi', 'bagaimanapun', 'nya', 'hehe','dgn','pa','bu', 'pak', 'ibu','fotocopy','print','ga','gak','gk','wkwkwk','ckckck','hahaha','di','pas','jgn','tdk','in','pas','an','yg','si','bapak','bp','bpk','ke'
);
}
function getStopNumber()
{
return array(
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '!', '@', '#', '$', '%', '"', '-', '+',']','[','{','}','|','!','(',')','^','&','*','`','~','?','/','.','<','>'
);
}
function getUnix($array){
error_reporting(0);
$unique = array_flip(array_flip($array));
//print_r($unique);
$jd=count($array);
//echo $jd."#<br>";
$m=0;
for($i=0;$i<$jd;$i++){
if(strlen($unique[$i])>0){
//echo "$m =".$unique[$i]."<br>";
$M[$m]=$unique[$i];
$m++;
}
}
return $M;
}
?>