How to Get Only Keys in PHP Array?

03-Apr-2023

.

Admin

How to Get Only Keys in PHP Array?

Hi Dev,

In this quick example, let's see how to get only keys in a PHP array. I explained simply step by step how to get only keys in the array. step by step explain how to find only keys in a PHP array. I would like to share with you how to find only keys in the array. Let's see bellow example how to get only keys in an array in PHP.

Today, I would like to show you how to get only keys in a PHP array. Here you will learn how to get only keys in the array. This post will give you a simple example of how to find only keys in a PHP array. if you have a question about how to find only keys in the array then I will give a simple example with a solution.

Example:


index.php

<?php

$array = array("UK"=>"London","India"=>"Delhi","Japan"=>"Tokyo");

print_r(array_keys($array));

?>

Output:

Array ( [0] => UK [1] => India [2] => Japan )

I hope it could help you...

#PHP