Convert Chinese date to PHP program _php Basics

Source: Internet
Author: User
This program will be the Chinese date output of 2001-12-23, and very good solution to the "ten" problem, such as "11" and "21" in the "Ten" Treatment! A slight modification can be changed to a function.
?
$str = "December 23, 2001";
echo $str. " <p> ";
$flag = 0;
$CN =array ("One", "two", "three", "four", "five", "six", "seven", "eight", "Nine", "Ten", "0", "0");
$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]== "Ten") 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 + +;
}
}
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.