Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7976929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:02:49+00:00 2026-06-04T09:02:49+00:00

As mentioned in this Meta Question , Facebook accepts the exact opposite case variation

  • 0

As mentioned in this Meta Question, Facebook accepts the exact opposite case variation of our password. For example:

1.- paSSw5ORD  (Original password)
2.- PAssW5ord  (Case altered to exact opposite, Capital->Small and vice-versa.)
3.- PaSSw5ORD  (Only first letter's case altered)

How to get the second variation, provided the first one is the original one, entered by user (or to get first one when user enters second version)?
Here is my take on this.

<?php

$pass = "paSSw5ORD"; //Example password
$pass_len = strlen($pass); //Find the length of string

for($i=0;$i<$pass_len;$i++){
    if(!(is_numeric($pass[$i]))){                 //If Not Number
        if($pass[$i]===(strtoupper($pass[$i]))){  //If Uppercase
            $pass2 .= strtolower($pass[$i]);      //Make Lowercase & Append
        } else{                                   // If Lowercase
            $pass2 .= strtoupper($pass[$i]);      //Make Uppercase & Append
        }
    } else{                  //If Number
        $pass2 .= $pass[$i]; //Simply Append
    }
}

//Test both
echo $pass."\r\n";
echo $pass2;
?>

But how to make it process passwords with special characters (all possible on a standard English keyboard?

!@#$%^&*()_+|?><":}{~[];',./     (Space also)

This does not work on all above special characters.

if(preg_match('/^\[a-zA-Z]+$/', "passWORD")){
//Special Character encountered. Just append it and
//move to next cycle of loop, similar to when we
//encountered a number in above code. 
}

I am no expert of RegEx, so How to modify the above RegEx to make sure it processes all the above mentioned special characters?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T09:02:51+00:00Added an answer on June 4, 2026 at 9:02 am

    Here is a function to toggle case of characters in a string .

    <?php
         $string = "Hello";                                      // the string which need to be toggled case
         $string_length = strlen($string);                      // calculate the string length
         for($i=0;$i<$string_length;$i++){                        // iterate to find ascii for each character
              $current_ascii = ord($string{$i});                 // convert to ascii code
              if($current_ascii>64 && $current_ascii<91){        // check for upper case character
                     $toggled_string .= chr($current_ascii+32);   // replace with lower case character
              }elseif($current_ascii>96 && $current_ascii<123){    // check for lower case character
                    $toggled_string .= chr($current_ascii-32);   // replace with upper case character
              }else{
                    $toggled_string .= $string{$i};               // concatenate the non alphabetic string.
                  }
            }
         echo "The toggled case letter for $string is <hr />".$toggled_string; // output will be hELLO
    ?>
    

    Hope this will help you

    Same example is given in this link .

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In this question , I mentioned my assumption that rubyforge gems are more official,
Some people have mentioned RockScroll and MetaScroll in This Question , but those only
I came across this question on a website. As mentioned there, it was asked
I am completely perplexed. I asked this question and it (any mentioned solution) doesn't
So, as mentioned in this answer and in the iOS 4.0 release notes ,
HI May i know how to make the scroll view as mentioned in this
I know this issue being mentioned before, but resolutions there didn't apply. I'm having
I have followed this tutorial here as mentioned exactly I now try to run
How to fix this regex in order to get the mentioned outcome ? regex:
This question is an attempt to find a practical solution for this question .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.