Tools, FAQ, Tutorials:
Retrieving All Keys from an Array in PHP
How To Get All the Keys Out of an Array in PHP?
✍: FYIcenter.com
Function array_keys() returns a new array that contains all the keys of a given array. Here is a PHP script on how to use array_keys():
<?php
$mixed = array();
$mixed["Zero"] = "PHP";
$mixed[1] = "Perl";
$mixed["Two"] = "Java";
$mixed["3"] = "C+";
$mixed[""] = "Basic";
$mixed[] = "Pascal";
$mixed[] = "FORTRAN";
$keys = array_keys($mixed);
print("Keys of the input array:\n");
print_r($keys);
?>
This script will print:
Keys of the input array:
Array
(
[0] => Zero
[1] => 1
[2] => Two
[3] => 3
[4] =>
[5] => 4
[6] => 5
)
⇒ Retrieving All Values from an Array in PHP
⇐ Finding a Given Value in an Array in PHP
2017-01-21, ∼2144🔥, 0💬
Popular Posts:
Where to find tutorials on Visual Studio? I want to know How to learn Visual Studio. Here is a large...
What Is session_register() in PHP? session_register() is old function that registers global variable...
How To Change Text Fonts for Some Parts of a Paragraph? If you want to change text fonts or colors f...
What are "*..." and "**..." Wildcard Parameters in Function Definitions? If you want to define a fun...
How To Protect Special Characters in Query String in PHP? If you want to include special characters ...