Use the array_keys () function to get the array keys and the array_values ββ() function to get the array values.
You want to get the values ββof the array:
$array = array( 3 => "Hello", 7 => "Moo", 45 => "America" ); $arrayValues = array_values($array);// returns all values with indexes echo '<pre>'; print_r($arrayValues); echo '</pre>';
Exit:
Array ( [0] => Hello [1] => Moo [2] => America )
You want to get the keys of an array:
$arrayKeys = array_keys($array);// returns all keys with indexes echo '<pre>'; print_r($arrayKeys); echo '</pre>';
Exit:
Array ( [0] => 3 [1] => 7 [2] => 45 )
Gufran Hasan Dec 12 '18 at 15:01 2018-12-12 15:01
source share