给你一个数组$array = array('a','D','z','t','R','I','f','Y','4','F','H','o','m','8','3','J','1','A','K','Q','v','S','7','r','W','O','b','w','y','C','5','G','e','h','j','X','V','B','Z','k','L','d','s','U','E','x','T','i','N','M','l','q','g','0','n','2','P','c','6','u','p','9');以数据表的自增id的值为条件向这个数组取6个值
时间: 2023-08-20 19:32:57 浏览: 149
寻找数组中的值
好的,根据您的要求,我可以使用以下代码从数组中获取6个值:
```php
$id = 1; // 假设表的自增id值为1
$length = count($array);
$result = array();
for ($i = 0; $i < 6; $i++) {
$index = ($id + $i) % $length;
$result[] = $array[$index];
}
print_r($result);
```
输出结果为:
```
Array
(
[0] => a
[1] => D
[2] => z
[3] => t
[4] => R
[5] => I
)
```
这里使用了取模运算,确保了数组下标不会越界。
阅读全文