Access PHP Array Keys with array_keys()

In PHP, you can use the array_keys() function to retrieve all keys of an array.示例如下:

<?php
$fruits = array("apple" => "red", "banana" => "yellow", "orange" => "orange");

$keys = array_keys($fruits);

print_r($keys);
?>

The code above will produce:

Array
(
    [0] => apple
    [1] => banana
    [2] => orange
)

This way you can access all keys and values of the array.

bannerAds