cvs: phpdoc /en/reference/array/functions key.xml

From: Date: Sat, 16 Aug 2003 15:33:22 +0000
Subject: cvs: phpdoc /en/reference/array/functions key.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969355833@lists.php.net to get a copy of this message
cece Sat Aug 16 11:33:22 2003 EDT Modified files: /phpdoc/en/reference/array/functions key.xml Log: added example Index: phpdoc/en/reference/array/functions/key.xml diff -u phpdoc/en/reference/array/functions/key.xml:1.4 phpdoc/en/reference/array/functions/key.xml:1.5 --- phpdoc/en/reference/array/functions/key.xml:1.4 Sun May 12 04:19:28 2002 +++ phpdoc/en/reference/array/functions/key.xml Sat Aug 16 11:33:22 2003 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.4 $ --> +<!-- $Revision: 1.5 $ --> <!-- splitted from ./en/functions/array.xml, last change in rev 1.2 --> <refentry id="function.key"> <refnamediv> @@ -15,6 +15,33 @@ <para> <function>key</function> returns the index element of the current array position. + </para> + <para> + <example> + <title><function>key</function> example</title> + <programlisting role="php"> +<![CDATA[ +<?php +$array = array ( + 'fruit1' => 'apple', + 'fruit2' => 'orange', + 'fruit3' => 'grape', + 'fruit4' => 'apple', + 'fruit5' => 'apple' +); + +// this cycle echoes all associative array +// key where value equals "apple" +while ($fruit_name = current($array)) { + if ($fruit_name == 'apple') { + echo key($array).'<br>'; + } + next($array); +} +?> +]]> + </programlisting> + </example> </para> <para> See also <function>current</function> and <function>next</function>.

« previous php.doc (#969355833) next »