mirror of
https://github.com/php/doc-ja.git
synced 2026-03-24 07:02:08 +01:00
191 lines
5.1 KiB
XML
191 lines
5.1 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: faa17c20aa7cdada1806b5b60d2c1b3bbcfff0d9 Maintainer: hirokawa Status: ready -->
|
|
<!-- CREDITS: shimooka,mumumu -->
|
|
<refentry xml:id="function.array-key-exists" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>array_key_exists</refname>
|
|
<refpurpose>指定したキーまたは添字が配列にあるかどうかを調べる</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>array_key_exists</methodname>
|
|
<methodparam><type class="union"><type>string</type><type>int</type><type>float</type><type>bool</type><type>resource</type><type>null</type></type><parameter>key</parameter></methodparam>
|
|
<methodparam><type>array</type><parameter>array</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
指定した <parameter>key</parameter> が配列に設定されている場合、
|
|
<function>array_key_exists</function> は &true; を返します。
|
|
<parameter>key</parameter> は配列添字として使用できる全ての値を使用可能です。
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>key</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
調べる値。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>array</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
キーが存在するかどうかを調べたい配列。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
&return.success;
|
|
</para>
|
|
<note>
|
|
<para>
|
|
<function>array_key_exists</function> は、最初のレベルのキーだけを捜します。
|
|
多次元配列のネストされたキーは、この関数では見つけられません。
|
|
</para>
|
|
</note>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>8.5.0</entry>
|
|
<entry>
|
|
<parameter>key</parameter> パラメータに
|
|
<type>null</type> を指定することは、推奨されなくなりました。
|
|
代わりに、空文字列を使ってください。
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>8.0.0</entry>
|
|
<entry>
|
|
<parameter>key</parameter> パラメータは
|
|
<type>bool</type>, <type>float</type>, <type>int</type>,
|
|
<type>null</type>, <type>resource</type>,
|
|
<type>string</type> を引数として受け入れるようになりました。
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>8.0.0</entry>
|
|
<entry>
|
|
<parameter>array</parameter> に <type>object</type> を渡すことは、
|
|
サポートされなくなりました。
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>7.4.0</entry>
|
|
<entry>
|
|
<parameter>array</parameter> に <type>object</type> を渡すことは、
|
|
推奨されなくなりました。
|
|
<function>property_exists</function> を代わりに使ってください。
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</refsect1>
|
|
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><function>array_key_exists</function> の例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$searchArray = ['first' => 1, 'second' => 4];
|
|
var_dump(array_key_exists('first', $searchArray));
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
bool(true)
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
<example>
|
|
<title><function>array_key_exists</function> 対 <function>isset</function></title>
|
|
<para>
|
|
<function>isset</function> は &null; 値を持つ配列キーに対して
|
|
&true; を返しません。一方、<function>array_key_exists</function> は
|
|
&true; を返します。
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$searchArray = ['first' => null, 'second' => 4];
|
|
|
|
var_dump(isset($searchArray['first']));
|
|
var_dump(array_key_exists('first', $searchArray));
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
bool(false)
|
|
bool(true)
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>isset</function></member>
|
|
<member><function>array_keys</function></member>
|
|
<member><function>in_array</function></member>
|
|
<member><function>property_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
|
|
-->
|