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

PHP Home Page

Manual Table of Contents
Up to Arrays
Quick Reference
English version of this pageGerman version of this pageItalian version of this pageFrench version of this pageHungarian version of this page
Arrays
* 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_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 -- 配列のキーをすべて返す

説明

array array_keys (array input [, mixed search_value])

array_keys()は、配列inputから 全てのキー(数値および文字列)を返します。

オプションsearch_valueが指定された場合、 指定した値に関するキーのみが返されます。指定されない場合は、 inputから全てのキーが返されます。

例 1. array_keys()の例


$array = array(0 => 100, "color" => "red");
array_keys($array);    // array(0, "color")を返します
      

array_values()も参照下さい。

注意: この関数は、PHP 4.0で追加されました。


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.