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

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -