- 相關推薦
轉(zhuǎn)換中文日期的PHP程序
本程序?qū)⒅形娜掌谳敵鰹?001-12-23,并很好解決了“十”的問題,如“十一”和“二十一”中“十”的處理!稍加修改可改為函數(shù)。跟隨小編去看看吧!希望對大家有所幫助!
<?
$str="二零○一年十二月二十三日";
echo $str."<p>";
$flag=0;
$cn=array("一","二","三","四","五","六","七","八","九","十","零","○");
$num=array("1","2","3","4","5","6","7","8","9","","0","0");
$len=strlen($str);
for ($i=0;$i<$len;$i+=2)
{
$array_str[$i]=substr($str,$i,2);
$cout=0;
while($cout<count($cn))
{
if ($array_str[$i]==$cn[$cout])
{
if ($flag==1)
echo "-";
if (($array_str[$i]=="十") and ($flag==1))
{
$temp[$cout]="1";
echo $temp[$cout];
$flag=2;break;
}
$temp[$cout]=$num[$cout];
echo $temp[$cout];
$flag=2;
break;
}
else
{
if (count($cn)==$cout+1)
$flag=1;
}
$cout++;
}
}
?>
【轉(zhuǎn)換中文日期的PHP程序】相關文章:
php時間戳與日期如何轉(zhuǎn)換09-30
php日期轉(zhuǎn)時間戳 指定日期轉(zhuǎn)換成時間戳09-26
關于PHP的日期與時間08-19
php字母大小如何轉(zhuǎn)換09-14
分析php日期轉(zhuǎn)時間戳06-11
php數(shù)據(jù)類型轉(zhuǎn)換詳解10-12
PHP字符集如何轉(zhuǎn)換07-13
PHP擴展程序講解11-10
php程序員11-01