1
0
mirror of https://github.com/php/doc-de.git synced 2026-03-29 18:52:13 +02:00
Files
archived-doc-de/reference/array/functions/in-array.xml
Oliver Albers a25c3bb452 Sync to en, credits to tom
git-svn-id: https://svn.php.net/repository/phpdoc/de/trunk@198701 c90b9560-bf6c-de11-be94-00142212c4b1
2005-10-18 13:19:44 +00:00

151 lines
3.8 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.8 $ -->
<!-- EN-Revision: 1.12 Maintainer: simp Status: ready -->
<!-- CREDITS: tom -->
<refentry id="function.in-array">
<refnamediv>
<refname>in_array</refname>
<refpurpose>Prüft, ob ein Wert in einem Array existiert</refpurpose>
</refnamediv>
<refsect1>
<title>Beschreibung</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>
Diese Funktion sucht in <parameter>haystack</parameter> nach
<parameter>needle</parameter> und gibt bei Erfolg &true; zurück,
andernfalls &false;.
</para>
<para>
Ist der dritte Parameter <parameter>strict</parameter> auf &true;
gesetzt, prüft <function>in_array</function> auch die
<link linkend="language.types">Typen</link> von
<parameter>needle</parameter> in <parameter>haystack</parameter>.
</para>
<note>
<para>
Ist <parameter>needle</parameter> ein String, erfolgt der Vergleich
unter Berücksichtigung der Groß- und Kleinschreibung.
</para>
</note>
<note>
<para>
In den PHP Versionen vor 4.2.0 durfte <parameter>needle</parameter>
kein Array sein
</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 "Irix gefunden";
}
if (in_array("mac", $os)) {
echo "mac gefunden";
}
?>
]]>
</programlisting>
<para>
Die zweite Bedingung schlägt fehl, da <function>in_array</function>
die Groß-/Kleinschreibung berücksichtigt, daher wird das obige
Programm folgendes ausgeben:
</para>
<screen role="php">
<![CDATA[
Irix gefunden
]]>
</screen>
</example>
</para>
<para>
<example>
<title><function>in_array</function> mit 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' gefunden mit strict check\n";
}
if (in_array(1.13, $a, true)) {
echo "1.13 gefunden mit strict check\n";
}
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
1.13 gefunden mit strict check
]]>
</screen>
</example>
</para>
<para>
<example>
<title><function>in_array</function> mit einem Array als 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' wurde gefunden\n";
}
if (in_array(array('f', 'i'), $a)) {
echo "'fi' wurde nicht gefunden\n";
}
if (in_array('o', $a)) {
echo "'o' wurde gefunden\n";
}
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
'ph' wurde gefunden
'o' wurde gefunden
]]>
</screen>
</example>
</para>
<para>
Siehe auch <function>array_search</function>,
<function>array_key_exists</function> und
<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
-->