Jump to content

Recommended Posts

if you convert a string to upper case and if it doesn't change compared to the way it looked like before... it's already uppercase

if (strtoupper($the_string) == $the_string) { 
  echo '$the_string contains only upper case letters 
         and maybe other non-letter characters'; 
} 

 

Link to comment
https://forums.phpfreaks.com/topic/92374-case-differentiation/#findComment-473282
Share on other sites

I mean like, I wanted it to explode (except put every letter instead of every word or whatever seperated by a colon for example)... then check the letter and the case. After that, it will echo an image of a letter in a font only I have...

Link to comment
https://forums.phpfreaks.com/topic/92374-case-differentiation/#findComment-473310
Share on other sites

For single character checks, you can do the strtoupper versus the original string as posted before, or use the PHP ord() function, and compare it with ASCII values for lowercase/uppercase letters.

 

ASCII values for lowercase: 97-122

ASCII values for uppercase: 65-90

Link to comment
https://forums.phpfreaks.com/topic/92374-case-differentiation/#findComment-473810
Share on other sites

<?php
$a = range('A', 'Z');
$trans = array(' ' => ' ');
foreach ($a as $k)
{
    $trans[$k] = "<img src='$k.png' />";
}

$data = "A B C D";
echo strtr ($data, $trans);
?>

 

 

gives-->

<img src='A.png' /> <img src='B.png' /> <img src='C.png' /> <img src='D.png' />

Link to comment
https://forums.phpfreaks.com/topic/92374-case-differentiation/#findComment-474373
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.