reset( $a );
unset( $a[ key($a)]);
一个更有用的版本:
// rewinds array's internal pointer to the first element
// and returns the value of the first array element.
$value = reset( $a );
// returns the index element of the current array position
$key = key( $a );
unset( $a[ $key ]);
功能:
// returns value
function array_shift_assoc( &$arr ){
$val = reset( $arr );
unset( $arr[ key( $arr ) ] );
return $val;
}
// returns [ key, value ]
function array_shift_assoc_kv( &$arr ){
$val = reset( $arr );
$key = key( $arr );
$ret = array( $key => $val );
unset( $arr[ $key ] );
return $ret;
}