Let S be an associative array in PHP, I need to retrieve and extract from it the first element, both the value and the key.
I would use
value1=array_pop
list($value, $key) = array(reset($s), key($s)); array_shift($s); // or just unset($s[$key]);
Of course you can split the first statement into two separate.