Jump to content

String Question


Mateobus

Recommended Posts

You can do it with preg_match() too, but this is probably one of the easiest ways:
[code]
$text = 'abCD';

// Make sure the string is always 2 characters or more otherwise substr() returns false
if (ctype_upper(substr($text, -2)) {
       echo "The string $text last 2 characters consists of uppercase letters.\n";
   } else {
       echo "The string $text last 2 characters do not consist of uppercase letters.\n";
   }
[/code]
Link to comment
https://forums.phpfreaks.com/topic/8606-string-question/#findComment-31570
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.