mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 08:58:56 +00:00
Added Thomas's contribution, plus more details on array_flip.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@47561 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
0817840cb9
commit
e4738deb2c
1 changed files with 27 additions and 4 deletions
|
@ -270,7 +270,20 @@ $even_arr = array_filter($array2, "even");
|
|||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
<function>Array_flip</function> returns an array in flip order.
|
||||
<function>array_flip</function> returns an array in flip order,
|
||||
i.e. keys from <parameter>trans</parameter> become values and
|
||||
<parameter>trans</parameter>'s values become keys.
|
||||
Note that <function>array_flip</function> works only with string
|
||||
and integer values, and it will display an alert if it detects
|
||||
invalid key or value (array, double, object, boolean).
|
||||
</para>
|
||||
<para>
|
||||
If a value has several occurences, the latest key will be
|
||||
used as its values, and all others will be lost.
|
||||
</para>
|
||||
<para>
|
||||
<function>array_flip</function> returns <literal>FALSE</literal>
|
||||
if it fails.
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
|
@ -281,6 +294,16 @@ $original = strtr ($str, $trans);
|
|||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title><function>Array_flip</function> example : collision</title>
|
||||
<programlisting role="php">
|
||||
$trans = array ("a" => 1, "b" => 1, "c" => 2);
|
||||
$trans = array_flip ($trans);
|
||||
// now $trans is : array(1 => "b", 2 => "c");
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
|
@ -1011,9 +1034,9 @@ $result_keyed = array_reverse ($input, TRUE);
|
|||
</example>
|
||||
</para>
|
||||
<para>
|
||||
This makes <varname>$result</varname> have <literal>array
|
||||
(array ("green", "red"), 4.0, "php")</literal>. But
|
||||
<varname>$result2[0]</varname> is still
|
||||
This makes both <varname>$result</varname> and <varname>$result_keyed</varname>
|
||||
be <literal>array(array ("green", "red"), 4.0, "php")</literal>. But
|
||||
<varname>$result_keyed[0]</varname> is still
|
||||
<literal>"php"</literal>.
|
||||
</para>
|
||||
<note>
|
||||
|
|
Loading…
Reference in a new issue