mirror of
https://github.com/macintoshplus/doc-fr.git
synced 2026-03-27 02:12:19 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/fr/trunk@78204 c90b9560-bf6c-de11-be94-00142212c4b1
100 lines
2.9 KiB
XML
100 lines
2.9 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- splitted from ./fr/functions/array.xml, last change in rev 1.30 -->
|
|
<!-- last change to 'array-keys' in en/ tree in rev 1.2 -->
|
|
<refentry id="function.array-keys">
|
|
<refnamediv>
|
|
<refname>array_keys</refname>
|
|
<refpurpose>Retourne toutes les clés d'un tableau</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>array</type><methodname>array_keys</methodname>
|
|
<methodparam><type>array</type><parameter>input</parameter></methodparam>
|
|
<methodparam choice="opt"><type>mixed</type><parameter>
|
|
search_value
|
|
</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>array_keys</function> retourne les clés numériques
|
|
et litérales du tableau <parameter>input</parameter>.
|
|
</para>
|
|
<para>
|
|
Si l'option <parameter>search_value</parameter> est spécifiée,
|
|
seules les clés ayant cette valeur seront retournées.
|
|
Sinon, toutes les clés de <parameter>input</parameter> sont
|
|
retournées.
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Exemple avec <function>array_keys</function></title>
|
|
<programlisting role="php">
|
|
<?php
|
|
$array = array(0 => 100, "couleur" => "rouge");
|
|
array_keys($array);
|
|
// retourne array(0, "couleur")
|
|
$array = array("bleu", "rouge", "vert", "bleu", "bleu");
|
|
array_keys($array, "bleu");
|
|
// retourne array(0, 3, 4)
|
|
$array = array( "couleur" => array("bleu", "rouge", "vert"),
|
|
"taille" => array("petit", "moyen", "grand") );
|
|
array_keys($array);
|
|
// retourne array("couleur", "taille")
|
|
?>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<note>
|
|
<para>
|
|
<function>array_keys</function> a été ajoutée en PHP
|
|
4. Ci-dessous, voici une implémentation qui fonctionnera sous PHP 3:
|
|
<example>
|
|
<title>
|
|
Implémentation de <function>array_keys</function> pour
|
|
les utilisateurs de PHP 3
|
|
</title>
|
|
<programlisting role="php">
|
|
<?php
|
|
function array_keys ($arr, $term="") {
|
|
$t = array();
|
|
while (list($k,$v) = each($arr)) {
|
|
if ($term && $v != $term) {
|
|
continue;
|
|
$t[] = $k;
|
|
}
|
|
return $t;
|
|
}
|
|
}
|
|
?>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</note>
|
|
<para>
|
|
Voir aussi
|
|
<function>array_values</function>.
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"../../../../manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|