1
0
mirror of https://github.com/php/doc-ru.git synced 2026-03-28 01:32:09 +01:00
Files
archived-doc-ru/reference/array/functions/in-array.xml
Hannes Magnusson 245266cba8 Upgrade to DocBook5:
- All id attributes are now xml:id
 - Add docbook namespace to all root elements
 - Replace <ulink /> with <link xlink:href />
 - Minor markup fixes here and there
 - Bump EN-Revision where appropriate


git-svn-id: https://svn.php.net/repository/phpdoc/ru/trunk@238337 c90b9560-bf6c-de11-be94-00142212c4b1
2007-06-23 13:31:28 +00:00

158 lines
4.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: 1.12 Maintainer: sveta Status: ready -->
<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/array.xml, last change in rev 1.56 -->
<refentry xml:id="function.in-array" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>in_array</refname>
<refpurpose>Проверить, присутствует ли в массиве значение</refpurpose>
</refnamediv>
<refsect1>
<title>Описание</title>
<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> и возвращает &true;
в случае удачи, &false; в противном случае.
</para>
<para>
Если третий параметр <parameter>strict</parameter> установлен в
&true; тогда функция <function>in_array</function>
также проверит соответствие <link linkend="language.types">types</link>
параметра <parameter>needle</parameter> и соответствующего значения массива
<parameter>haystack</parameter>.
</para>
<note>
<para>
Если <parameter>needle</parameter> - строка, сравнение будет регистрозависмым.
</para>
</note>
<note>
<para>
В PHP версий, более ранних, чем 4.2.0 параметр <parameter>needle</parameter>
не может быть массивом.
</para>
</note>
<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 "Got Irix";
}
if (in_array("mac", $os)) {
echo "Got mac";
}
?>
]]>
</programlisting>
<para>
Второго совпадения не будет, потому что <function>in_array</function>
регистрозависима, таким образом, программа выведет:
</para>
<screen>
<![CDATA[
Got 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' found with strict check
";
}
if (in_array(1.13, $a, true)) {
echo "1.13 found with strict check
";
}
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
1.13 found with strict check
]]>
</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' найдено
";
}
if (in_array(array('f', 'i'), $a)) {
echo "'fi' найдено
";
}
if (in_array('o', $a)) {
echo "'o' найдено
";
}
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
'ph' найдено
'o' найдено
]]>
</screen>
</example>
</para>
<para>
См. также <function>array_search</function>,
<function>array_key_exists</function> и
<function>isset</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
-->