-
-
Save parzibyte/96717eedf4dfef552b2b32b8e5b7f3a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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