Posted By

nicolaspar on 07/24/06


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

meth


Php extraer mayor valor de un array


 / Published in: PHP
 

  1. function mayorValor( $array ){
  2. $a = array_unique( $array );
  3. $s = 0;
  4. if( is_array( $a ) )
  5. foreach( $a as $v )
  6. $s = intval( $v ) > $s ? $v : $s;
  7. return $s;
  8. }
  9.  
  10. $arr = array(9,3,5,6,7,8,99,9,7,8,9,4);
  11. echo mayorValor( $arr ) #out 99

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: SegFault on July 25, 2006

Puedes usar directamente la función max para ello.

You need to login to post a comment.