比较PHP中的两个多值 [英] Compare two multiple values in PHP
问题描述
我正在尝试将多个值与多个值进行比较但它不起作用,并且它使用单个值
我尝试过:
I am trying to compare multiple values with multiple values but it not working, and its working with single value
What I have tried:
$weekdays = @implode(',', $_POST['weekdays']);
$weekdayss = trim($weekdays," ");/*remove space*/
$repeat_every = 1
$i = 1;
while ($i <= 15) {
# code...
if ((date('l', strtotime($date))) == $weekdayss) {
# code...
echo $date." ----> ".date('l', strtotime($date))."<br/>";
}
$date = date ("Y-m-d", strtotime("+".$repeat_every." day", strtotime($date)));
$i++;
}
这里的工作日是从ckeckbox中选出的,可能是一个或多个
如果工作日等于星期日或任何其他日输出日期和日期,但如果星期天的星期一,它没有输出任何东西。请尽快帮助我
这是输出
循环运行15次15次我得到2个星期日
Here weekdayss is selected from ckeckbox it may be one or multiple
if weekdayss is equals to sunday or any other day it outputs the date and day but if weekdayss in sunday, Monday it outputs nothing. Please help me asap
Here is the output
Loop is running 15 times so for 15 time I am getting 2 sundays
Start Date : 2018-07-04
Week Days : Sunday
2018-07-08 ----> Sunday
2018-07-15 ----> Sunday
此输出没问题,但我也想要这个
This output is ok but I also want this as well
<pre>
Start Date : 2018-07-04
Week Days : Sunday, Monday
2018-07-08 ----> Sunday
2018-07-09 ----> Monday
2018-07-15 ----> Sunday
2018-07-16 ----> Monday
推荐答案
weekdays = @implode(',',
weekdays = @implode(',',
_POST ['weekdays' ]);
_POST['weekdays']);
weekdayss = trim(
weekdayss = trim(
这篇关于比较PHP中的两个多值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!