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);
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments