,值班代码如何写
求助,值班代码怎么写
最近在做单位的网站,基础很薄弱,很多东西都是边看书边百度摸索着做的
最近想要实现在主页上显示每天的值班人员,四天轮一次。
我写的代码如下。
$zbb0=array("张三","李四","王五")
$zbb1=array("张三1","李四1","王五1")
$zbb2=array("张三2","李四2","王五2")
$zbb3=array("张三3","李四3","王五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";}
?>
大概意思就是获取当前日期是今年的第几天,再除以四得出余数,根据余数的数值显示相应的人员
------解决方案--------------------
$zbb0=array("张三","李四","王五");
$zbb1=array("张三1","李四1","王五1");
$zbb2=array("张三2","李四2","王五2");
$zbb3=array("张三3","李四3","王五3");
$date_time=getdate(time());
$yday=$date_time["yday"];
$day=$yday%4; //余数
$zb='zbb'.$day; //是哪天的变量
$zbb=$$zb;
print_r($zbb);
------解决方案--------------------
- PHP code
$zb=array( 1=>array("张三","李四","王五") ,array("张三1","李四1","王五1"), array("张三2","李四2","王五2"), array("张三3","李四3","王五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; } ?> <br><font color="#e78608">------解决方案--------------------</font><br> $zbb = array(<br> array("张三","李四","王五"),<br> array("张三1","李四1","王五1"),<br> array("张三2","李四2","王五2"),<br> array("张三3","李四3","王五3"),<br>);<br>print_r($zbb[date('z')%4]);<br>或<br>echo join(',', $zbb[date('z')%4]); <div class="clear"> </div>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



If you're looking for a way to automatically create and name files and folders based on system timestamps, you've come to the right place. There is a super simple way to accomplish this task. The created folders or files can then be used for various purposes such as storing file backups, sorting files based on date, etc. In this article, we will explain in some very simple steps how to automatically create files and folders in Windows 11/10 and name them according to the system’s timestamp. The method used is a batch script, which is very simple. Hope you enjoyed reading this article. Section 1: How to automatically create and name a folder based on the current timestamp of the system Step 1: First, navigate to the parent folder where you want to create the folder,

When developing using PHP programs, you often encounter some warning or error messages. Among them, one error message that may appear is: PHPWarning:date()expectsparameter2tobelong,stringgiven. The error message means: the second parameter of the function date() is expected to be a long integer (long), but what is actually passed to it is a string (string). So, we

Title: Example of using the Array.Sort function to sort an array in C# Text: In C#, array is a commonly used data structure, and it is often necessary to sort the array. C# provides the Array class, which has the Sort method to conveniently sort arrays. This article will demonstrate how to use the Array.Sort function in C# to sort an array and provide specific code examples. First, we need to understand the basic usage of the Array.Sort function. Array.So

1. Introduction The Date class in the java.util package represents a specific time, accurate to milliseconds. If we want to use our Date class, then we must introduce our Date class. Writing the year directly into the Date class will not produce the correct result. Because Date in Java is calculated from 1900, so as long as you fill in the first parameter with the number of years since 1900, you will get the year you want. The month needs to be subtracted by 1, and the day can be inserted directly. This method is rarely used, and the second method is commonly used. This method is to convert a string that conforms to a specific format, such as yyyy-MM-dd, into Date type data. First, define an object of Date type Date

How to get millisecond representation of date using getTime() method of Date class In Java, Date class is a class used to represent date and time. It provides many useful methods to manipulate and obtain information about date objects. Among them, the getTime() method is an important method in the Date class, which can return the millisecond representation of the date object. Next, we will detail how to use this method to obtain the millisecond representation of a date, and provide corresponding code examples. Using the Date class

There are many excellent calendar libraries and date libraries in Python for us to use. These libraries can help us handle date and calendar related operations. Next, I will introduce you to several common choices and provide corresponding code examples. Datetime library: Datetime is Python's built-in date and time processing module. It provides many date and time related classes and methods, which can be used to process dates, times, time differences and other operations. Sample code: importdatetime#Get the current date

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

When programming in PHP, we often need to merge arrays. PHP provides the array_merge() function to complete array merging, but when the same key exists in the array, this function will overwrite the original value. In order to solve this problem, PHP also provides an array_merge_recursive() function in the language, which can merge arrays and retain the values of the same keys, making the program design more flexible. array_merge
