PHP date loop knowledge essential for PHPer

Source: Internet
Author: User
Number of days of the week in a loop (the red letter shows the number of days of the current week) $ week_array = array (1, 2, 4, 5, 6, 7); foreach ($ week_arrayAS $ key = $ value) {if ($ value = date (w) $ value = fontcolor = red. $ valu

Number of days of the week in a loop (the red letter shows the number of days of the week)
$ Week_array = array (1, 2, 3, 4, 5, 6, 7 );
Foreach ($ week_array AS $ key => $ value)
{
If ($ value = date ("w "))
$ Value = "". $ value ."";
Echo $ value ."";
}

The number of days in the current month is output cyclically (the red letter shows the current number)
For ($ day = date ("t"); $ day> 0; $ day --)
$ Month_array [] = $ day;
Sort ($ month_array );
Foreach ($ month_array AS $ key => $ value)
{
If ($ value = date ("j "))
$ Value = "". $ value ."";
Echo $ value ."";
} Echo 'month of the current year :';
For ($ I = 1; $ I <= 12; $ I ++ ){
If ($ I = date ('N') echo'';
Echo "$ I \ t ";
If ($ I = date ('N') echo'
';
}

Echo"
\ N number of days in the current month :";
For ($ I = 1; $ I <= date ('t'); $ I ++ ){
If ($ I = date ('J') echo'';
Echo "$ I \ t ";
If ($ I = date ('J') echo'
';
}
Echo"
\ N days of the week :";
$ Arr = array ('day', 'yi', '2', '3', '4', '5', '6 ');
For ($ I = 0; $ I <6; $ I ++ ){
If ($ I = date ('w') echo'';
Echo $ arr [$ I]. "\ t ";
If ($ I = date ('w') echo'
';
}
Echo"
\ N hour of the current day :";
For ($ I = 0; $ I <24; ++ $ I ){
If ($ I = date ('g') echo'';
Echo "$ I \ t ";
If ($ I = date ('g') echo'
';

}
 

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.