function demo($a=null,$b=null)
{
$result = array();
for ($i=$a[0]; $i<=$a[1]; $i++) {
foreach ($b as $b_key => $b_value) {
$result[$i][$b_value] = $i / $b_value; //假设b中所有都能整除 , 先把值存起来
if ($i % $b_value != 0) {
unset($result[$i]); // 一旦b中有一个数字不满足, 例如 1000 / 7 , 那就跳出循环, 移除 $result['1000']
break;
}
}
}
return $result;
}
print_r(demo([1000,1600],[4,5,6]));
//结果 (浏览器输出我就不调格式了)
//结果数组中 key $a范围内满足的数, value是数组(这个数组中key是b中的值, value是整除的结果)
//其他情况你自己再判断吧(比如 $a 和 $b 是一个数字)
Array
(
[1020] => Array
(
[4] => 255
[5] => 204
[6] => 170
)
[1080] => Array
(
[4] => 270
[5] => 216
[6] => 180
)
[1140] => Array
(
[4] => 285
[5] => 228
[6] => 190
)
[1200] => Array
(
[4] => 300
[5] => 240
[6] => 200
)
[1260] => Array
(
[4] => 315
[5] => 252
[6] => 210
)
[1320] => Array
(
[4] => 330
[5] => 264
[6] => 220
)
[1380] => Array
(
[4] => 345
[5] => 276
[6] => 230
)
[1440] => Array
(
[4] => 360
[5] => 288
[6] => 240
)
[1500] => Array
(
[4] => 375
[5] => 300
[6] => 250
)
[1560] => Array
(
[4] => 390
[5] => 312
[6] => 260
)
)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…