string array_peek( array $a, string $k )
This function returns a string of the next key in sequential order of $a, delimited by $k. Useful when iterating through an array. and needing to "peek ahead" of a key.
Parameters:
$a - The array (haystack)
$k - the key prior to expected result (needle)
Example:
<?php
$a = array('x' => 1, 'i' => 2, 'g' => 3, 'k' => 4, 'l' => 5);
echo array_peek($a, 'x');
?>
The above example will output:
i
<?php
function array_peek($a, $k) {
foreach($a as $x => $v) {
if (isset($h)) return $x;
if ($x == $k) $h = 1;
}
}
?>