Posted By

nicolaspar on 10/16/10


Tagged

php String upper mayusculas abuse abuso


Versions (?)

Abuse UpperCase String


 / Published in: PHP
 

use: <?=validarAbusoMayusculas('HOLA>

  1. function validarAbusoMayusculas( $str ){
  2. return getStrSize( $str ) < 83 ? strtolower($str) : $str;
  3. }
  4. function getStrSize( $str ){
  5. $largo=strlen($str);
  6. $peso=0;
  7. for( $i=0;$i<$largo;++$i ) $peso = $peso + ord( $str[$i] );
  8. if( $largo > 0 ) return $peso/$largo;
  9. else return 100; #ok
  10. }

Report this snippet  

You need to login to post a comment.