Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created February 14, 2019 15:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/96717eedf4dfef552b2b32b8e5b7f3a6 to your computer and use it in GitHub Desktop.
Save parzibyte/96717eedf4dfef552b2b32b8e5b7f3a6 to your computer and use it in GitHub Desktop.
<?php
function esMayuscula($cadena)
{
# También podrías usar mb_strtoupper
return $cadena === strtoupper($cadena);
}
# Probar
$cadenas = ["Hola", "HOLA", "hola"];
foreach ($cadenas as $cadena) {
if (esMayuscula($cadena)) {
echo "$cadena es mayúscula\n";
} else {
echo "$cadena no es mayúscula\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment