Ver Mensaje Individual
  #9 (permalink)  
Antiguo 26/02/2013, 08:33
Avatar de JeMaGa
JeMaGa
 
Fecha de Ingreso: julio-2011
Ubicación: Bogota
Mensajes: 430
Antigüedad: 12 años, 9 meses
Puntos: 4
Respuesta: tomar el mayor valor de un arreglo

este es todo el codigo que tengo

Código HTML:
Ver original
  1.     <title>NUMEROS MAYOR Y MENOR</title>
  2. </head>
  3.  
  4. <form action="nNumerosmayor.php" name="Nmayor" method="post">
  5.   <table width="60%" border="1">
  6.     <tr>
  7.       <td colspan="3"><center>NOTAS</center></td>
  8.     </tr>
  9.     <tr>
  10.       <td><textarea name="valores[]"></textarea></td>
  11.      
  12.       <?php
  13.      
  14.           //$Area=implode(",",$_POST['valores']);
  15.      
  16.        $array= $_REQUEST['valores'];
  17.         //foreach($array as $key => $value){
  18.            
  19.             //$val = max(array($value));
  20.             //echo max(($array));
  21.             //echo "Numero ".max(array($value));
  22.             //echo max(array($Area));
  23.             //echo $Area;
  24.            
  25.         //}
  26.        
  27. foreach($array as $d)
  28. {
  29.     if(empty($nro))
  30.     {
  31.         $nro = $d;
  32.         $mayor = $nro;
  33.     }
  34.     else
  35.     {
  36.         if($d > $mayor)
  37.         {
  38.             $mayor = $d;
  39.         }
  40.     }
  41. }
  42.  
  43. echo $mayor;
  44. var_dump($array);
  45.  
  46.       ?>
  47.      
  48.     </tr>
  49.   </table>
  50.   <input type="submit" name="enviar" value="Enviar">
  51. </form>
  52. </body>
  53. </html>