1
0
mirror of https://github.com/php/doc-de.git synced 2026-03-26 08:12:07 +01:00
Files
archived-doc-de/reference/array/functions/in-array.xml
Thomas Schoefbeck bcdc9299c3 sync to en
git-svn-id: https://svn.php.net/repository/phpdoc/de/trunk@133570 c90b9560-bf6c-de11-be94-00142212c4b1
2003-06-29 07:44:02 +00:00

149 lines
3.6 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.6 $ -->
<!-- EN-Revision: 1.8 Maintainer: tom Status: ready -->
<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)) {
print "Got Irix";
}
if (in_array ("mac", $os)) {
print "Got mac";
}
?>
]]>
</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[
Got Irix
]]>
</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>
<para>
Dies wird folgendes anzeigen:
</para>
<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";
}
?>
/* Ausgabe:
'ph' wurde gefunden
'o' wurde gefunden
*/
]]>
</programlisting>
</example>
</para>
<para>
Siehe auch <function>array_search</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
-->