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]);