someone say "I want to delete a words in strings where less than 3 character", or "what the best simple way to remove words less than two character in string".
Read more »
Labels: PHP, Source Code, Webmaster
Labels: PHP, Source Code, Webmaster
Labels: Blog, blog template, javascript, PHP, Webmaster, Website
Labels: css, html, javascript, PHP, Webmaster
Labels: blog template, Blogger, English Blog, Java, javascript, PHP, Webmaster
Labels: Blog, blog template, Blogger, PHP, Webmaster
Labels: blog template, Blogger, Java, PHP, Webmaster
$date = 'Your post or comments date here, e.g 2015-04-05 01:05:13';
function umur_tulisan($datetime, $full = false) {
$sekarang = new DateTime;
$dulu = new DateTime($datetime);
$rentang = $sekarang->diff($dulu);
$rentang->w = floor($rentang->d / 7);
$rentang->d -= $rentang->w * 7;
//Dictionary : $sekarang = $now, $dulu = $ago, $rentang = $distance or what ever
$string = array(
'y' => 'tahun',
'm' => 'bulan',
'w' => 'minggu',
'd' => 'hari',
'h' => 'jam',
'i' => 'menit',
's' => 'detik',
);
foreach ($string as $k => &$v) {
if ($rentang->$k) {
$v = $rentang->$k . ' ' . $v . ($rentang->$k > 1 ? '' : '');
} else {
unset($string[$k]);
}
}
if (!$full) $string = array_slice($string, 0, 1);
return $string ? implode(', ', $string) . ' yang lalu' : 'baru saja';
}
echo umur_tulisan($date);
Labels: blog template, PHP, Source Code, Webmaster
$hari='counter/harian-'.date("dmy").'.txt';
$bulan='counter/bulanan-'.date("my").'.txt';
$total='counter/total-counter.txt';
$perhari = file($hari);
$perbulan = file($bulan);
$semuanya = file($total);
$perhari[0] ++;
$perbulan[0] ++;
$semuanya[0] ++;
$fp = fopen($hari, "w");
fputs($fp , "$perhari[0]");
fclose($fp);
$fp = fopen($bulan, "w");
fputs($fp , "$perbulan[0]");
fclose($fp);
$fp = fopen($total, "w");
fputs($fp , "$semuanya[0]");
fclose($fp);
Labels: blog template, PHP, Webmaster
Labels: blog template, PHP, Webmaster