mirror of
https://github.com/php/doc-pl.git
synced 2026-04-23 23:08:09 +02:00
c4e2175cc8
git-svn-id: https://svn.php.net/repository/phpdoc/pl/trunk@338467 c90b9560-bf6c-de11-be94-00142212c4b1
148 lines
3.9 KiB
XML
148 lines
3.9 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- EN-Revision: 12572e7195011e598e7b9ad0da9ec0d7073c063d Maintainer: leszek Status: ready -->
|
|
<!-- $Revision$ -->
|
|
<!-- CREDITS: sobak -->
|
|
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.array-key-exists">
|
|
<refnamediv>
|
|
<refname>array_key_exists</refname>
|
|
<refpurpose>Sprawdza czy podany klucz lub indeks istnieje w tablicy</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>array_key_exists</methodname>
|
|
<methodparam><type>mixed</type><parameter>klucz</parameter></methodparam>
|
|
<methodparam><type>array</type><parameter>tablica</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>array_key_exists</function> zwraca &true; jeśli
|
|
podany <parameter>klucz</parameter> jest ustawiony w tablicy.
|
|
<parameter>klucz</parameter> może być dowolną wartością możliwą
|
|
dla indeksu tablicy.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>klucz</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Wartość do sprawdzenia.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>tablica</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Tablica z kluczami do sprawdzenia.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
&return.success;
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Przykład użycia <function>array_key_exists</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$tablica = array('pierwszy' => 1, 'drugi' => 4);
|
|
if (array_key_exists('pierwszy', $tablica)) {
|
|
echo "Element 'pierwszy' istnieje w tablicy";
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<example>
|
|
<title><function>array_key_exists</function> vs <function>isset</function></title>
|
|
<para>
|
|
<function>isset</function> nie zwraca &true; dla kluczy
|
|
przypisanych do wartości &null;, podczas gdy
|
|
<function>array_key_exists</function> tak.
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$tablica = array('pierwszy' => 1, 'drugi' => 4);
|
|
|
|
// zwraca false
|
|
isset($tablica['pierwszy']);
|
|
|
|
// zwraca true
|
|
array_key_exists('pierwszy', $tablica);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
<note>
|
|
<para>
|
|
Z powodu kompatybilności wstecznej, <function>array_key_exists</function>
|
|
zwróci &true; także wtedy, gdy <parameter>klucz</parameter> jest właściwością
|
|
zdefiniowaną w ramach <type>obiektu</type> podanego jako parametr
|
|
<parameter>tablica</parameter>. Nie powinno się polegać na tym zachowaniu
|
|
i powinno się zadbać, aby <parameter>tablica</parameter> była
|
|
rzeczywiście typu <type>array</type>.
|
|
</para>
|
|
<para>
|
|
Aby sprawdzić czy właściwość istnieje w obiekcie, użyj
|
|
<function>property_exists</function>.
|
|
</para>
|
|
</note>
|
|
</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
|
|
-->
|