mirror of
https://github.com/php/doc-es.git
synced 2026-03-29 01:42:12 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@301165 c90b9560-bf6c-de11-be94-00142212c4b1
136 lines
4.4 KiB
XML
136 lines
4.4 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 96c9d88bad9a7d7d44bfb7f26c226df7ee9ddf26 Maintainer: gerardocdc Status: ready -->
|
|
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.max">
|
|
<refnamediv>
|
|
<refname>max</refname>
|
|
<refpurpose>Encontrar el valor más alto</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>mixed</type><methodname>max</methodname>
|
|
<methodparam><type>array</type><parameter>values</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<methodsynopsis>
|
|
<type>mixed</type><methodname>max</methodname>
|
|
<methodparam><type>mixed</type><parameter>value1</parameter></methodparam>
|
|
<methodparam><type>mixed</type><parameter>value2</parameter></methodparam>
|
|
<methodparam choice="opt"><type>mixed</type><parameter>value3...</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Si el primer y único parámetro es una matriz, <function>max</function>
|
|
devuelve el valor más alto en esa matriz. Si al menos dos parámetros son
|
|
entregados, <function>max</function> devuelve el mayor de estos valores.
|
|
</para>
|
|
<note>
|
|
<para>
|
|
PHP evaluará un valor <type>string</type> no-numérico como
|
|
<literal>0</literal> si se compara con un <type>integer</type>, pero aun
|
|
devuelve la cadena si ésta es vista como el valor numérico más alto. Si
|
|
varios argumentos evalúan a <literal>0</literal>,
|
|
<function>max</function> devolverá el valor de cadena alfanumérica más
|
|
alto si se da alguna cadena, o de lo contrario se devuelve un
|
|
<literal>0</literal> numérico.
|
|
</para>
|
|
</note>
|
|
</refsect1>
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>values</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Una matriz que contiene los valores.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
<function>max</function> devuelve el mayor valor numérico de los parámetros.
|
|
Si varios valores pueden considerarse del mismo tamaño, se devolverá el listado en primer lugar.
|
|
</para>
|
|
<para>
|
|
Cuando <function>max</function> debe evaluar varios <type>array</type>s, devuelve
|
|
el array de mayor tamaño. Si todos los arrays tienen el mismo tamaño,
|
|
<function>max</function> empleará la ordenación lexicográfica para encontrar el valor a devolver.
|
|
</para>
|
|
<para>
|
|
Cuando se debe comparar un <type>string</type>, se le considerará como un <type>integer</type> en la comparación.
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Ejemplos de uso de <function>max</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
echo max(1, 3, 5, 6, 7); // 7
|
|
echo max(array(2, 4, 5)); // 5
|
|
|
|
// Cuando 'hola' es convertido en integer se convierte en 0. Ambos parámetros son
|
|
// del mismo tamaño por lo que el orden en el que son colocados determina el resultado
|
|
echo max(0, 'hola'); // 0
|
|
echo max('hola', 0); // hola
|
|
|
|
echo max('42', 3); // '42'
|
|
|
|
// En este caso 0 > -1, asi que 'hola' es el valor devuelto.
|
|
echo max(-1, 'hola'); // hola
|
|
|
|
// Con varias matrices de diferentes tamaño, max devuelve el de mayor tamaño
|
|
$val = max(array(2, 2, 2), array(1, 1, 1, 1)); // array(1, 1, 1, 1)
|
|
|
|
// Con varias matrices, max las compara de izquierda a derecha
|
|
// empleando el orden lexicográfico, así que en nuestro ejemplo: 2 == 2, pero 4 < 5
|
|
$val = max(array(2, 4, 8), array(2, 5, 7)); // array(2, 5, 7)
|
|
|
|
// Si se pasan una matriz y una no-matriz, la matriz
|
|
// es devuelta siempre ya que se considera el valor mayor
|
|
$val = max('cadena', array(2, 5, 7), 42); // array(2, 5, 7)
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>min</function></member>
|
|
<member><function>count</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
|
|
-->
|