php - Set current array using a string -
if $point 333 (for example) want current($ids) 444:
$ids = array(111, 222, 333, 444); $point = 333;
if $point 444, current($ids) 111 , on.
i have code, looking more simple:
$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) { next($ids); } $toecho = next($ids); if (!$toecho) { $toecho = reset($ids); }
Comments
Post a Comment