- ARRAY_KEYS
array_keys — Return
all the keys of an array
Description
array array_keys
( array $input [, mixed $search_value [, bool $strict]] )
array_keys() returns the
keys, numeric and string, from the input array.
If the optional
search_value is specified, then only the keys for that value are
returned. Otherwise, all the keys from the input are returned. As of PHP
5, you can use strict parameter for comparison including type (===).
Parameters
input
An array containing keys to return.
search_value
If specified, then only keys containing these values are
returned.
strict
As of PHP 5, this parameter determines if strict
comparision (===) should be used during the search.
Return Values
Returns an
array of all the keys in input.
Examples
<?php $array = array(0 => 100, "color" => "red"); $a = array_keys($array); foreach($a as $a1) { echo "<br> keys are== $a1"; } $array = array("blue", "red", "green", "blue", "blue"); $a = array_keys($array, "blue"); foreach($a as $a1) { echo "<br> blue is match keys number are== $a1"; } ?> output is keys are== 0 keys are== color blue is match keys number are== 0 blue is match keys number are== 3 blue is match keys number are== 4
Tags
ARRAY_KEYS