Files
php-doc-ru/reference/array/functions/in-array.xml
Shein Alexey 9bfed200dc Updated translation.
git-svn-id: https://svn.php.net/repository/phpdoc/ru/trunk@307949 c90b9560-bf6c-de11-be94-00142212c4b1
2011-02-02 10:31:23 +00:00

212 lines
5.5 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 96c9d88bad9a7d7d44bfb7f26c226df7ee9ddf26 Maintainer: shein Status: ready -->
<!-- Reviewed: no -->
<!-- $Revision$ -->
<refentry xml:id="function.in-array" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>in_array</refname>
<refpurpose>Проверяет, присутствует ли в массиве значение</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>bool</type><methodname>in_array</methodname>
<methodparam><type>mixed</type><parameter>needle</parameter></methodparam>
<methodparam><type>array</type><parameter>haystack</parameter></methodparam>
<methodparam choice="opt"><type>bool</type><parameter>strict</parameter></methodparam>
</methodsynopsis>
<para>
Ищет в <parameter>haystack</parameter> значение <parameter>needle</parameter>.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>needle</parameter></term>
<listitem>
<para>
Искомое значение.
</para>
<note>
<para>
Если <parameter>needle</parameter> - строка, сравнение
будет произведено с учетом регистра.
</para>
</note>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>haystack</parameter></term>
<listitem>
<para>
Массив.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>strict</parameter></term>
<listitem>
<para>
Если третий параметр <parameter>strict</parameter> установлен в
&true; тогда функция <function>in_array</function>
также проверит соответствие <link linkend="language.types">типов</link>
параметра <parameter>needle</parameter> и соответствующего
значения массива <parameter>haystack</parameter>.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Возвращает &true;, если <parameter>needle</parameter> был найден
в массиве, и &false; в обратном случае.
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>4.2.0</entry>
<entry>
<parameter>needle</parameter> теперь может быть массивом.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Пример использования <function>in_array</function></title>
<programlisting role="php">
<![CDATA[
<?php
$os = array("Mac", "NT", "Irix", "Linux");
if (in_array("Irix", $os)) {
echo "Нашел Irix";
}
if (in_array("mac", $os)) {
echo "Нашел mac";
}
?>
]]>
</programlisting>
<para>
Второго совпадения не будет, потому что <function>in_array</function>
регистрозависима, таким образом, программа выведет:
</para>
<screen>
<![CDATA[
Нашел Irix
]]>
</screen>
</example>
</para>
<para>
<example>
<title>Пример использования <function>in_array</function> с параметром strict</title>
<programlisting role="php">
<![CDATA[
<?php
$a = array('1.10', 12.4, 1.13);
if (in_array('12.4', $a, true)) {
echo "'12.4' найдено со строгой проверкой\n";
}
if (in_array(1.13, $a, true)) {
echo "1.13 найдено со строгой проверкой\n";
}
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
1.13 найдено со строгой проверкой
]]>
</screen>
</example>
</para>
<para>
<example>
<title>Пример использования <function>in_array</function> с массивом в качестве параметра 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' найдено\n";
}
if (in_array(array('f', 'i'), $a)) {
echo "'fi' найдено\n";
}
if (in_array('o', $a)) {
echo "'o' найдено\n";
}
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
'ph' найдено
'o' найдено
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>array_search</function></member>
<member><function>isset</function></member>
<member><function>array_key_exists</function></member>
</simplelist>
</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:"~/.phpdoc/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
-->