mirror of
https://github.com/php/doc-ja.git
synced 2026-03-25 15:42:08 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/ja/trunk@326764 c90b9560-bf6c-de11-be94-00142212c4b1
164 lines
4.9 KiB
XML
164 lines
4.9 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 9b2a0aeeba7b81d686d232f4baa6ca4adae28a07 Maintainer: hirokawa Status: ready -->
|
|
<!-- CREDITS: shimooka -->
|
|
<refentry xml:id="function.array-search" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>array_search</refname>
|
|
<refpurpose>指定した値を配列で検索し、見つかった場合に対応するキーを返す</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>mixed</type><methodname>array_search</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><initializer>false</initializer></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>
|
|
オプションの3番目のパラメータ <parameter>strict</parameter> に
|
|
&true; が指定された場合、<function>array_search</function> は
|
|
<emphasis>identical</emphasis> 要素を
|
|
<parameter>haystack</parameter> から探します。つまり、
|
|
<parameter>haystack</parameter> の中で
|
|
<parameter>needle</parameter> の型に一致するかどうか、
|
|
そしてオブジェクトが同一のインスタンスであるかどうかも確認します。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
<parameter>needle</parameter> が見つかった場合に配列のキー、
|
|
それ以外の場合に &false; を返します。
|
|
</para>
|
|
<para>
|
|
もし <parameter>haystack</parameter> に 1 つ以上の
|
|
<parameter>needle</parameter> に見つかった場合、
|
|
最初にマッチしたキーが返されます。
|
|
全てのマッチした値に対するキーを返すためには、代わりに
|
|
<function>array_keys</function> にパラメータ
|
|
<parameter>search_value</parameter> を付けて使用してください。
|
|
</para>
|
|
&return.falseproblem;
|
|
</refsect1>
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<para>
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>5.3.0</entry>
|
|
<entry>
|
|
他のすべての内部関数と同様、無効なパラメータが渡されたときに
|
|
<function>array_search</function> が &null; を返すようになりました。
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>4.2.0</entry>
|
|
<entry>
|
|
PHP 4.2.0 以前では、<function>array_search</function> は、
|
|
失敗した場合に &false; ではなく &null; を返します。
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><function>array_search</function> の例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$array = array(0 => 'blue', 1 => 'red', 2 => 'green', 3 => 'red');
|
|
|
|
$key = array_search('green', $array); // $key = 2;
|
|
$key = array_search('red', $array); // $key = 1;
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>array_keys</function></member>
|
|
<member><function>array_values</function></member>
|
|
<member><function>array_key_exists</function></member>
|
|
<member><function>in_array</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
|
|
-->
|