You need array_keys function: https://www.php.net/manual/en/function.array-keys.php
array_keys
$a = ['Mountain' => 1, 'Forest' => 2, 'Space' => 1]; print_r(array_keys($a));
Will output
Array ( [0] => Mountain [1] => Forest [2] => Space )
1.4m articles
1.4m replys
5 comments
57.0k users