array_keys()
functionYou can use the PHP array_keys()
function to get all the keys out of an associative array.
Let's try out an example to understand how this function works:
<?php
$cities = array("France"=>"Paris", "India"=>"Mumbai", "UK"=>"London", "USA"=>"New York");
// Get keys from cities array
print_r(array_keys($cities));
?>
You can also use the PHP foreach
loop to find or display all the keys, like this:
<?php
$cities = array("France"=>"Paris", "India"=>"Mumbai", "UK"=>"London", "USA"=>"New York");
// Loop through cities array
foreach($cities as $key => $value){
echo $key . " : " . $value . "<br>";
}
?>
Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on harsukh21@gmail.com
How to select an element with multiple classes with jQuery
Specify Class Names without Spaces in Be...How to change href attribute of a hyperlink using jQuery
Use the jQuery .attr() Method You can...How to sort an array values alphabetically in PHP
Use the PHP sort() and rs...How to get number of elements in a div using jQuery
Use the jQuery .length property You c...Excel and csv import export using maatwebsite in laravel example
We are share with you in this tutorials...