Example 1 — List All Keys
Get the keys of an associative array as a simple list.
<?php
$data = ["a" => 1, "b" => 2, "c" => 3];
$keys = array_keys($data);
echo implode(", ", $keys), PHP_EOL; How It Works
- Create an associative array. The keys are
a,bandc. - Call array_keys(). It collects the keys into a new array.
- Join them.
implode()puts a comma between each key. - Print the text. The values
1, 2, 3are not included.

