在这里,我想比较两个数组结果,结果如下所示,StreamController
看起来像这样
array1
array(7) { [0]=> string(6) "M" [1]=> string(7) "T" [2]=> string(9) "W" [3]=> string(8) "T" [4]=> string(6) "F" [5]=> string(8) "S" [6]=> string(6) "S" }
看起来像这样
array2
在这里,我想将array(7) { [0]=> string(5) "15:00" [1]=> string(5) "14:00" [2]=> string(5) "13:00" [3]=> string(0) "" [4]=> string(5) "12:00" [5]=> string(5) "11:00" [6]=> string(5) "10:00" }
的{{1}}与first value
的{{1}}行与第二行进行比较,如果值返回true,则应执行函数,如果值返回空它应该执行另一个函数
所以我完成了我的代码
array1
答案 0 :(得分:1)
你应该做那样的事情:
$array1 = array("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday");
$array2 = array("15:00","14:00","13:00","", "12:00","11:00","10:00");
foreach($array1 as $index => $val) {
echo "compare $val to $array2[$index] <br />";
}
此代码返回:
compare Monday to 15:00
compare Tuesday to 14:00
compare Wednesday to 13:00
compare Thursday to
compare Friday to 12:00
compare Saturday to 11:00
compare Sunday to 10:00