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
Use array_keys
to get the keys:
$keys = array_keys($array);
$key = $keys[0];
$value = $array[$key];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.