【发布时间】:2018-09-08 02:09:25
【问题描述】:
我有两个表,我想使用函数compare() 的特定比较来比较元素。问题是,我有两张表:一张是静态的,一张是动态的。我从第一个 table1 中获得了第一个元素 $results1[$i],并将它与 table2 中的第一个元素进行比较(我们假设 table2 在时间 0 有一个元素)。如果compare() 函数返回一个小于3 的数字,我将table1 的第一个元素添加到table2,然后我必须将table1 的第二个元素与table2 的all 元素进行比较。
for($i = 0; $i < count ( $results1 ); $i++) {
echo ' value 1 : ' . $results1 [$i] . ' ';
for($k = 0; $k < count ( $results2 ); $k++) {
echo ' value 2 : ' . $results2 [$k] . ' ';
compare($results1 [$i],$results2 [$k]);
}
}
function compare($element1_table1,$element2_table2){
if ($results_of_comparison< 3){
//we add element1 to table2 and
//then we compare the next element of table 1 with all elements of table2
}
}
如何使用循环比较表 1 的下一个元素与表 2 的所有元素? 有人可以帮帮我吗?
【问题讨论】:
-
If result
-
如果比较的结果是