<?php
$x=6;
$y=9;
$time = array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
for ($i=$x;$i<=count($y);$i++)
{
If($x!=$y)
{
$time[$i]=1;
}
}
?>
Depending on the value of x and y,the values in array should change. In this example... array[5] until array[8] should be value 1. The value of x and y will not same.
根据x和y的值,数组中的值应该更改。在这个例子中...... array [5]直到array [8]应该是值1.x和y的值不相同。
1 个解决方案
#1
1
Not a very good question, but I'm a little bored. So for fun:
这不是一个很好的问题,但我有点无聊。所以为了好玩:
array_splice($time, $x-1, $y-$x-1, array_fill(0, $y-$x+1, 1));
Not exactly sure of the logic using 6 and 9 and array[5] until array[8] is, but adjust the numbers to fit the range.
不完全确定使用6和9以及数组[5]的逻辑直到数组[8],但调整数字以适应范围。
#1
1
Not a very good question, but I'm a little bored. So for fun:
这不是一个很好的问题,但我有点无聊。所以为了好玩:
array_splice($time, $x-1, $y-$x-1, array_fill(0, $y-$x+1, 1));
Not exactly sure of the logic using 6 and 9 and array[5] until array[8] is, but adjust the numbers to fit the range.
不完全确定使用6和9以及数组[5]的逻辑直到数组[8],但调整数字以适应范围。