Php extraer mayor valor de un array


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  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

You need to login to post a comment.