Home / PHP Tips Generated By ChatGPT / Getting Keys of an Array in PHP Retrieve all the keys from an array using array_keys(). Source Code $assoc = ['name' => 'John', 'age' => 25, 'city' => 'New York']; $keys = array_keys($assoc); print_r($keys);