I have the following code:
if ($_POST[\'submit\'] == \"Next\") {
foreach($_POST[\'info\'] as $key => $value) {
echo $value;
}
}
How about something like this? Read off the first key and value using key()
and current()
, then (EDIT: Don't use array_shift()
to dequeue the front element from the arrayarray_shift()
, it renumbers any numerical indices in the array, which you don't always want!).
"ONE!!", 'two' => "TWO!!", 'three' => "TREE", 4 => "Fourth element", 99 => "We skipped a few here.." ) ; $firstKey = key( $arr ) ; $firstVal = current( $arr ) ; echo( "OK, first values are $firstKey, $firstVal
" ) ; ####array_shift( $arr ) ; #'dequeue' front element# BAD! renumbers! unset( $arr[ $firstKey ] ) ; # BETTER! echo( "Now for the rest of them
" ) ; foreach( $arr as $key=>$val ) { echo( "$key => $val
" ) ; } ?>