Get key & value from associative array using numeric index

arrays, associative-array, php

Solution

Use `array_keys` to get the keys:

$keys = array_keys($array);
$key = $keys[0];
$value = $array[$key];

Problem

I have an array: ``` $array = array( '001' => '555', '002' => '666', '003' => '777' ); ``` I wish to get the key & value using number index ``` $key = $array[0]; $value = $array[0][]; ``` I am using a number index as the size of the array when executed will be unknown

Original source