If I had an array like:
$array[\'foo\'] = 400; $array[\'bar\'] = \'xyz\';
And I wanted to get the first item out of that array without knowing
Fake loop that breaks on the first iteration:
$key = $value = NULL; foreach ($array as $key => $value) { break; } echo "$key = $value\n";
Or use each() (warning: deprecated as of PHP 7.2.0):
reset($array); list($key, $value) = each($array); echo "$key = $value\n";