How to get numeric index of associative array in php?
The array_keys() function is an inbuilt function in PHP which is used to return either all the keys of an array or the subset of the keys.
1. Code:
<?php
// Program to print index of an associative array
// Declare an associative array
$assoc_array=array("Soltuts"=>10, "for"=>15, "sol"=>20);
// Print index with corresponding key
// using array_keys() function
print_r(array_keys($assoc_array));
?>
2. Example:
Input:
Array("Soltuts"=>10, "for"=>15, "sol"=>20);
Output:
Array ( [0] => Soltuts [1] => for [2] => sol )