mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
- Added documentation/example for the use as an array as the first parameter
to in_array(). git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@67565 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
ee04b8522b
commit
d97896b3e4
1 changed files with 32 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.151 $ -->
|
||||
<!-- $Revision: 1.152 $ -->
|
||||
<reference id="ref.array">
|
||||
<title>Array Functions</title>
|
||||
<titleabbrev>Arrays</titleabbrev>
|
||||
|
@ -2886,6 +2886,12 @@ blue, large, sphere, medium
|
|||
a case-sensitive manner.
|
||||
</para>
|
||||
</note>
|
||||
<note>
|
||||
<para>
|
||||
In PHP versions before 4.2.0 <parameter>needle</parameter> was not
|
||||
allowed to be an array.
|
||||
</para>
|
||||
</note>
|
||||
<para>
|
||||
<example>
|
||||
<title><function>in_array</function> example</title>
|
||||
|
@ -2901,7 +2907,7 @@ if (in_array ("mac", $os)) {
|
|||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
The second condition fails because <function>in_array()</function>
|
||||
The second condition fails because <function>in_array</function>
|
||||
is case-sensitive, so the program above will display:
|
||||
<screen role="php">
|
||||
<![CDATA[
|
||||
|
@ -2936,6 +2942,30 @@ if (in_array(1.13, $a, TRUE))
|
|||
</para>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title><function>in_array</function> with an array as needle</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$a = array(array('p', 'h'), array('p', 'r'), 'o');
|
||||
|
||||
if (in_array(array ('p', 'h'), $a))
|
||||
echo "'ph' is found\n";
|
||||
if (in_array(array ('f', 'i'), $a))
|
||||
echo "'fi' is not found\n";
|
||||
if (in_array('o', $a))
|
||||
echo "'o' is found\n";
|
||||
?>
|
||||
|
||||
// This will output:
|
||||
|
||||
'ph' is found
|
||||
'o' is found
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
See also <function>array_search</function>.
|
||||
</para>
|
||||
|
|
Loading…
Reference in a new issue