Quantcast
Channel: PHP array next value of a value - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Answer by Denny Sutedja for PHP array next value of a value

$
0
0

hope this help:

while (($next = next($items)) !== NULL) {       if ($next == 'three') {             break;          }}$next = next($items);echo $next;

for large array u can use :

$src = array_search('five',$items); // get array key$src2 = array_search($src,array_keys($items)); // get index array (start from 0)$key = array_keys($items); // get array by number, not associative anymore// then what u need just insert index array+1 on array by number ($key[$src2+1])echo $items[$key[$src2+1]];

Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>