mirror of
https://github.com/php/doc-es.git
synced 2026-03-25 07:52:21 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@172353 c90b9560-bf6c-de11-be94-00142212c4b1
151 lines
3.8 KiB
XML
151 lines
3.8 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.3 $ -->
|
|
<!-- EN-Revision: 1.12 Maintainer: baoengb Status: ready -->
|
|
<!-- splitted from ./es/functions/array.xml, last change in rev 1.1 -->
|
|
<refentry id="function.in-array">
|
|
<refnamediv>
|
|
<refname>in_array</refname>
|
|
<refpurpose>Revisa si un valor existe en una matriz</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Descripción</title>
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>in_array</methodname>
|
|
<methodparam><type>mixed</type><parameter>aguja</parameter></methodparam>
|
|
<methodparam><type>array</type><parameter>pajar</parameter></methodparam>
|
|
<methodparam choice="opt"><type>bool</type><parameter>strict</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Busca la <parameter>aguja</parameter> en el <parameter>pajar</parameter>,
|
|
y devuelve &true; si se encuentra y &false; en caso contrario.
|
|
</para>
|
|
<para>
|
|
Si el tercer parámetro <parameter>strict</parameter> es definido en
|
|
&true; entonces la función <function>in_array</function> también
|
|
revisará los <link linkend="language.types">tipos</link> de
|
|
la <parameter>aguja</parameter> en el <parameter>pajar</parameter>.
|
|
</para>
|
|
<note>
|
|
<para>
|
|
Si <parameter>needle</parameter> es una cadena, la comparación es
|
|
hecha de una forma sensible a mayúsculas y minúsculas.
|
|
</para>
|
|
</note>
|
|
<note>
|
|
<para>
|
|
En PHP antes de 4.2.0. <parameter>needle</parameter> no le era
|
|
permitido ser una matriz.
|
|
</para>
|
|
</note>
|
|
<para>
|
|
<example>
|
|
<title>Ejemplo de <function>in_array</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$os = array ("Mac", "NT", "Irix", "Linux");
|
|
if (in_array ("Irix", $os))
|
|
print "Encontrado Irix";
|
|
if (in_array("mac", $os)) {
|
|
echo "Encontrado mac";
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
<para>
|
|
La segunda condición falla porque <function>in_array</function>
|
|
es CASE-SENSITIVE, por lo que el programa desplegará:
|
|
</para>
|
|
<screen>
|
|
<![CDATA[
|
|
Got Irix
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Ejemplo de STRICT <function>in_array</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$a = array('1.10', 12.4, 1.13);
|
|
|
|
if (in_array('12.4', $a, true)) {
|
|
echo "'12.4' Encontrado con chequeo STRICT\n";
|
|
}
|
|
|
|
if (in_array(1.13, $a, true)) {
|
|
echo "1.13 Encontrado con chequeo STRICT\n";
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
1.13 Encontrado con chequeo STRICT
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title><function>in_array</function> with an array as needle</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$a = array(array('p', 'h'), array('p', 'r'), 'o');
|
|
|
|
if (in_array(array('p', 'h'), $a)) {
|
|
echo "Se encontro 'ph'\n";
|
|
}
|
|
|
|
if (in_array(array('f', 'i'), $a)) {
|
|
echo "Se encontro 'fi'\n";
|
|
}
|
|
|
|
if (in_array('o', $a)) {
|
|
echo "Se encontro 'o'\n";
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
Se encontro 'ph'
|
|
Se encontro 'o'
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
Vea también <function>array_search</function>,
|
|
<function>array_key_exists</function>, y
|
|
<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
|
|
-->
|