How to write the duty code

Source: Internet
Author: User
For help, how do I write the duty code on the website that is currently working on the organization? the foundation is very weak. many things are being read while Baidu is exploring. Recently, I want to display the employees on duty every day on the homepage, it is a four-day round. The code I wrote is as follows. & Lt ;? Php $ zbb0 = array (& quot; Zhang San & quot;, & quot; Li Si & quot;, & quot; Wang Wu & q help, how to write the duty code
Recently, I am working on a website with a weak foundation. many things are made by Baidu while reading books.
Recently, we want to display the daily staff on the home page, which is a four-day round.
The code I wrote is as follows.
$ Zbb0 = array ("zhang san", "Li Si", "Wang Wu ")
$ Zbb1 = array ("zhang san 1", "Li Si 1", "Wang Wu 1 ")
$ Zbb2 = array ("zhang san 2", "Li Si 2", "Wang Wu 2 ")
$ Zbb3 = array ("zhang san 3", "Li Si 3", "Wang Wu 3 ")
$ Date_time = getdate (time ));
$ Yday = $ date_time ["yday"];
If ($ yday % 4 = 0 ){
Echo "$ zbb0 ";}
If ($ yday % 4 = 1 ){
Echo "$ zbb1 ";}
If ($ yday % 4 = 2 ){
Echo "$ zbb2 ";}
If ($ yday % 4 = 3 ){
Echo "$ zbb3 ";}
?>
The approximate meaning is to obtain the day of the year from the current date, divide by four to get the remainder, and then display the corresponding personnel according to the remainder value.


------ Solution --------------------
$ Zbb0 = array ("zhang san", "Li Si", "Wang Wu ");
$ Zbb1 = array ("zhang san 1", "Li Si 1", "Wang Wu 1 ");
$ Zbb2 = array ("zhang san 2", "Li Si 2", "Wang Wu 2 ");
$ Zbb3 = array ("zhang san 3", "Li Si 3", "Wang Wu 3 ");
$ Date_time = getdate (time ());
$ Yday = $ date_time ["yday"];
$ Day = $ yday % 4; // remainder

$ Zb = 'zbb '. $ day; // The date variable.
$ Zbb =$ $ zb;
Print_r ($ zbb );
------ Solution --------------------
PHP code
  Array ("zhang san", "Li Si", "Wang Wu"), array ("zhang san 1", "Li Si 1", "Wang Wu 1"), array ("zhang san 2 ", "Li Si 2", "Wang Wu 2"), array ("zhang san 3", "Li Si 3", "Wang Wu 3"); $ today = date ("N "); switch ($ today % 4) {case 1: print_r ($ zb [1]); break; case 2: print_r ($ zb [2]); break; case 3: print_r ($ zb [3]); break; case 4: print_r ($ zb [3]); break ;}?>
------ Solution --------------------
$ Zbb = array (
Array ("zhang san", "Li Si", "Wang Wu "),
Array ("zhang san 1", "Li Si 1", "Wang Wu 1 "),
Array ("zhang san 2", "Li Si 2", "Wang Wu 2 "),
Array ("zhang san 3", "Li Si 3", "Wang Wu 3 "),
);
Print_r ($ zbb [date ('Z') % 4]);
Or
Echo join (',', $ zbb [date ('Z') % 4]);

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.