★ wanayoo — archive 1999 http://www.php.net/manual/hu/function.array-keys.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to Tömbök
Quick Reference
English version of this pageGerman version of this pageJapanese version of this pageItalian version of this pageFrench version of this page
Tömbök
* array
* array_count_values
* array_diff
* array_flip
* array_intersect
* array_keys
* array_merge
* array_merge_recursive
* array_multisort
* array_pad
* array_pop
* array_push
* array_rand
* array_reverse
* array_shift
* array_slice
* array_splice
* array_unique
* array_unshift
* array_values
* array_walk
* arsort
* asort
* compact
* count
* current
* each
* end
* extract
* in_array
* key
* krsort
* ksort
* list
* next
* pos
* prev
* range
* reset
* rsort
* shuffle
* sizeof
* sort
* uasort
* uksort
* usort
Manual: array_keys
View the source code for this pageSearch the site



Previous page
 array_intersect
 Updated
Sat, 12 Aug 2000
array_merge 
Next page


array_keys

(PHP4 )

array_keys -- Return all the keys of an array

Description

array array_keys (array input [, mixed search_value])

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.

Példa 1. Array_keys() example


$array = array (0 => 100, "color" => "red");
array_keys ($array);       // returns array (0, "color")

$array = array (1, 100, 2, 100);
array_keys ($array, 100);  //  returns array (0, 2) 
      

See also array_values().


User Contributed Notes: array_keys


david@audiogalaxy.com
30-Jan-2000 08:53
Are array_keys() and array_values() guaranteed to list elements from an input array in the same order?


vraravam@thoughtworks.com
14-Jul-2000 05:25
I am desperately trying to find a corresponding function for array_keys() in PHP3. I am using version 3.1.16. If anybody knows any such function/method, please email me at
vraravam@thoughtworks.com

Thanks in advance



scott@cyberwar.com
15-Jul-2000 02:39
Below is a function that I wrote that acts the same as array_keys, but works in PHP3:


<pre>
function array_keys ($x) {
for($i=0;$i&#60;count($x);$i++) {
$y=each($x);
$z[$i]=$y[0];
}
return $z;
}
</pre>



marksg@chello.nl
13-Aug-2000 12:26
In the above example, they say:
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.

$array = array (1, 100, 2, 100);
array_keys ($array, 100); // returns array (0, 2)

should the return then be: array (1, 3) in stead of: array (0, 2) ??



 About Notes


Previous page
 array_intersect
 Updated
Sat, 12 Aug 2000
array_merge 
Next page





Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.