Archive for the ‘ PHP ’ Category
php – Chuyển từ IP sang Country [ ip 2 country ]
Ta dùng file countries.php:
<?php
$anp_cd["AD"]=array("Andorra", "Europe", "Andorra la Vella", "Euro");
$anp_cd["AE"]=array("United Arab Emirates", "Middle East", "Abu Dhabi", "UAE Dirham");
$anp_cd["AF"]=array("Afghanistan", "Asia", "Kabul", "Afghani");
$anp_cd["AG"]=array("Antigua and Barbuda", "Central America and the Caribbean", "Saint John's", "East Caribbean Dollar");
$anp_cd["AI"]=array("Anguilla", "Central America and the Caribbean", "The Valley", "East Caribbean Dollar");
$anp_cd["AL"]=array("Albania", "Europe", "Tirana", "Lek");
$anp_cd["AM"]=array("Armenia", "Commonwealth of Independent States", "Yerevan", "Armenian Dram");
$anp_cd["AN"]=array("Netherlands Antilles", "Central America [ READ MORE ]
So sánh 2 ngày
Comparing Dates
<?php
// create timestamps for two dates
$date1 = mktime(0,0,0,2,1,2007);
$date2 = mktime(1,0,0,2,1,2007);
// compare timestamps
// to see which represents an earlier date
if ($date1 > $date2) {
$str = date ("d-M-Y H:i:s", $date2) . " comes before " .?
date ("d-M-Y H:i:s", $date1);
} else if ($date2 > $date1) {
$str = date ("d-M-Y H:i:s", $date1) . " comes before " .?
date [ READ MORE ]
PHP – Tính Can Chi
Xác định 1 năm can chi là gì, cái này tớ chuyển từ C qua
Đây là hàm php đã chuyển:
<?php
function canchi($nam)
{
$acan = array("Giap", "At", "Binh", "Dinh", "Mau", "Ky", "Canh", "Tan", "Nham", "Quy");
$achi = array("Ty", "Suu", "Dan", "Meo", "Thin", "Ty", "Ngo", "Mao", "Than", "Dau", "Tuat", "Hoi");
$can = $acan[($nam+6)%10];
$chi = $achi[($nam+8)%12];
return $can." ".$chi;
}
echo canchi(1988);
?>
Còn đây là [ READ MORE ]