function tamanho_apropriado($tamanho){ if (!is_numeric($tamanho)){ return false; } else { switch ($tamanho){ case strlen($tamanho) < 4: $numero = number_format($tamanho/1,0); return $numero ." Bytes"; break; case strlen($tamanho) < 8: $numero = number_format($tamanho/1024,1); return $numero ." KBytes"; break; case strlen($tamanho) < 11: $numero = number_format($tamanho/1048576,0); return $numero ." MBytes"; break; case strlen($tamanho) >= 11: $numero = number_format($tamanho/1073741824,0); return $numero ." GBytes"; break; } } } ?>