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@158370 c90b9560-bf6c-de11-be94-00142212c4b1
103 lines
3.2 KiB
XML
103 lines
3.2 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.5 $ -->
|
|
<!-- EN-Revision: 1.9 Maintainer: lboshell Status: ready -->
|
|
<!-- splitted from ./en/functions/array.xml, last change in rev 1.2 -->
|
|
<refentry id="function.array-search">
|
|
<refnamediv>
|
|
<refname>array_search</refname>
|
|
<refpurpose>
|
|
Busca un valor determinado en una matriz y devuelve la clave
|
|
correspondiente en caso de éxito
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Descripción</title>
|
|
<methodsynopsis>
|
|
<type>mixed</type><methodname>array_search</methodname>
|
|
<methodparam><type>mixed</type><parameter>aguja</parameter></methodparam>
|
|
<methodparam><type>array</type><parameter>pajar</parameter></methodparam>
|
|
<methodparam choice="opt"><type>bool</type><parameter>estricto</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Busca en el <parameter>pajar</parameter> por la
|
|
<parameter>aguja</parameter> y retorna la clave de ésta si
|
|
se encuentra en la matriz, o &false; de lo contrario.
|
|
</para>
|
|
<note>
|
|
<para>
|
|
Si <parameter>aguja</parameter> es una cadena, la
|
|
comparación es realizada de forma sensible a
|
|
mayúsculas y minúsculas.
|
|
</para>
|
|
</note>
|
|
<note>
|
|
<para>
|
|
En versiones de PHP anteriores a 4.2.0,
|
|
<function>array_search</function> devuelve &null; en caso de
|
|
fallo, en lugar de &false;.
|
|
</para>
|
|
</note>
|
|
<para>
|
|
Si el opcional tercer argumento, <parameter>estricto</parameter>,
|
|
se define como &true; entonces la función
|
|
<function>array_search</function> también realizará
|
|
un chequeo sobre los tipos de datos de
|
|
<parameter>aguja</parameter> en el <parameter>pajar</parameter>.
|
|
</para>
|
|
|
|
<para>
|
|
Si la <parameter>aguja</parameter> es encontrada en
|
|
el <parameter>pajar</parameter> más de una vez, la primera
|
|
clave coincidente es devuelta. Para devolver las claves de todos
|
|
los valores coincidentes, use en su
|
|
lugar <function>array_keys</function> con el parámetro
|
|
opcional
|
|
<parameter>valor_busqueda</parameter>.
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Ejemplo de <function>array_search</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$matriz = array(0 => 'blue', 1 => 'red', 2 => 'green', 3 => 'red');
|
|
|
|
$clave = array_search('green', $matriz); // $clave = 2;
|
|
$clave = array_search('red', $matriz); // $clave = 1;
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
|
|
&return.falseproblem;
|
|
<para>
|
|
Vea también <function>array_keys</function>,
|
|
<function>array_values</function>,
|
|
<function>array_key_exists</function>, y
|
|
<function>in_array</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
|
|
-->
|