reference/array/functions/key.xml
0a192fcd9cc43c0007de795063b4494974058992
...
...
@@ -1,4 +1,4 @@
1
-
<?xml version="1.0" encoding="iso-8859-1"?>
1
+
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
3
<!-- splitted from ./en/functions/array.xml, last change in rev 1.2 -->
4
4
<refentry xml:id="function.key" xmlns="http://docbook.org/ns/docbook">
...
...
@@ -9,8 +9,8 @@
9
9
<refsect1 role="description">
10
10
&reftitle.description;
11
11
<methodsynopsis>
12
-
<type>mixed</type><methodname>key</methodname>
13
-
<methodparam><type>array</type><parameter role="reference">array</parameter></methodparam>
12
+
<type class="union"><type>int</type><type>string</type><type>null</type></type><methodname>key</methodname>
13
+
<methodparam><type class="union"><type>array</type><type>object</type></type><parameter>array</parameter></methodparam>
14
14
</methodsynopsis>
15
15
<para>
16
16
<function>key</function> returns the index element of the current array
...
...
@@ -35,9 +35,31 @@
35
35
<refsect1 role="returnvalues">
36
36
&reftitle.returnvalues;
37
37
<para>
38
-
Returns the index.
38
+
The <function>key</function> function simply returns the
39
+
key of the array element that's currently being pointed to by the
40
+
internal pointer. It does not move the pointer in any way. If the
41
+
internal pointer points beyond the end of the elements list or the array is
42
+
empty, <function>key</function> returns &null;.
39
43
</para>
40
44
</refsect1>
45
+

46
+
<refsect1 role="changelog">
47
+
&reftitle.changelog;
48
+
<informaltable>
49
+
<tgroup cols="2">
50
+
<thead>
51
+
<row>
52
+
<entry>&Version;</entry>
53
+
<entry>&Description;</entry>
54
+
</row>
55
+
</thead>
56
+
<tbody>
57
+
&standard.changelog.calling-on-objects;
58
+
</tbody>
59
+
</tgroup>
60
+
</informaltable>
61
+
</refsect1>
62
+

41
63
<refsect1 role="examples">
42
64
&reftitle.examples;
43
65
<para>
...
...
@@ -57,7 +79,7 @@ $array = array(
57
79
// key where value equals "apple"
58
80
while ($fruit_name = current($array)) {
59
81
if ($fruit_name == 'apple') {
60
-
echo key($array).'<br />';
82
+
echo key($array), "\n";
61
83
}
62
84
next($array);
63
85
}
...
...
@@ -67,9 +89,9 @@ while ($fruit_name = current($array)) {
67
89
&example.outputs;
68
90
<screen>
69
91
<![CDATA[
70
-
fruit1<br />
71
-
fruit4<br />
72
-
fruit5<br />
92
+
fruit1
93
+
fruit4
94
+
fruit5
73
95
]]>
74
96
</screen>
75
97
</example>
...
...
@@ -81,11 +103,12 @@ fruit5<br />
81
103
<simplelist>
82
104
<member><function>current</function></member>
83
105
<member><function>next</function></member>
106
+
<member><function>array_key_first</function></member>
107
+
<member><link linkend="control-structures.foreach">foreach</link></member>
84
108
</simplelist>
85
109
</para>
86
110
</refsect1>
87
111
</refentry>
88
-

89
112
<!-- Keep this comment at the end of the file
90
113
Local variables:
91
114
mode: sgml
...
...
@@ -97,7 +120,7 @@ sgml-indent-step:1
97
120
sgml-indent-data:t
98
121
indent-tabs-mode:nil
99
122
sgml-parent-document:nil
100
-
sgml-default-dtd-file:"../../../../manual.ced"
123
+
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
101
124
sgml-exposed-tags:nil
102
125
sgml-local-catalogs:nil
103
126
sgml-local-ecat-files:nil
104
127