PHP – String – mb_strtoupper
Función que convierte cualquier texto de minúsculas a mayúsculas, incluso letras con acentos u otros caráctares especiales.
/**
* Class HelperString
*/
abstract class HelperString
{
/**
* Convierte un string a mayúsculas.
* Es insensible a lo acéntos.
*
* @param string $txt
*
* @return string
*/
public static function toUpper($txt)
{
if (function_exists('mb_strtoupper')) {
return mb_strtoupper($txt); // Convierte carcateres especiales
}
return strtoupper($txt);
}
}
Ejemplos
$key = HelperSTring::toUpper('Funciona OK');
echo $key; // FUNCIONA OK
$key = HelperSTring::toUpper('1234567890?¿áéíóúàèòñ*+@#');
echo $key; // 1234567890?¿ÁÉÍÓÚÀÈÒÑ*+@#
