如果$point是333(例如),我希望当前($ids)为444:
$ids = array(111, 222, 333, 444);
$point = 333;
如果$point是444,当前($ids)为111等等
我有这个代码,但我在寻找更简单的东西:
$ids = array(111, 222, 333, 444, 555);
$point = array_search(555, $ids);
while(key($ids) != $point) {
next($ids);
}
$point = next($ids);
if($point == NULL) {
$point = reset($ids);
}
echo $point;
未找到下一个时重置阵列
while(key($ids) != $point) {
if (next($ids) === false) reset($ids);
}
while(key($ids) != $point) {
next($ids);
}
$toEcho = next($ids);
if (!$toEcho) {
$toEcho = reset($ids);
}