Voting

: min(five, two)?
(Example: nine)

The Note You're Voting On

nospam at dyce dot losethisbit dot com
16 years ago
Just a useful version which returns a simple array with the first key and value. Porbably a better way of doing it, but it works for me ;-)

<?php

function array_kshift(&$arr)
{
list(
$k) = array_keys($arr);
$r = array($k=>$arr[$k]);
unset(
$arr[$k]);
return
$r;
}

// test it on a simple associative array
$arr = array('x'=>'ball','y'=>'hat','z'=>'apple');

print_r($arr);
print_r(array_kshift($arr));
print_r($arr);

?>

Output:

Array
(
[x] => ball
[y] => hat
[z] => apple
)
Array
(
[x] => ball
)
Array
(
[y] => hat
[z] => apple
)

<< Back to user notes page

To Top