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

  • Home
  • SEARCH
  • 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 8817477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:51:31+00:00 2026-06-14T04:51:31+00:00

I am trying to replace every character from a string with it’s opposite but

  • 0

I am trying to replace every character from a string with it’s opposite but the following code is replacing only chars with chars but it does not recognize ASCII codes.

Can you please help me? Can you please tell me why? I have tried using the chr function but it doesn’t work. It shows me nothing.

Here is my code:

<?php
function flip($v)
{
    $flipped="";
    $size=strlen($v);

    $array=str_split($v,1); 

    for($i=0;$i<$size;$i++)
    {
        switch($array[$i])
            {
                case 'a': $flipped .= '\u0250';
                            break;
                case 'b' : $flipped .='q';
                            break;
                case 'c' : $flipped .='\u0254';
                            break;
                case 'd': $flipped .='p';
                            break;
                case 'e': $flipped .='\u01DD';
                            break;
                case 'f': $flipped .='\u025F';
                            break;
                case 'g' : $flipped .='\u0183';
                            break;
                case 'h': $flipped .='\u0265';
                            break;
                case 'i' : $flipped .='\u0131';
                            break;
                case 'j' : $flipped .='\u027E';
                            break;
                case 'k' : $flipped .='\u029E';
                            break;
                case 'l' : $flipped .='\u0283';
                            break;
                case 'm' : $flipped .='\u026F';
                            break;
                case 'n' : $flipped .='u';
                            break;
                case 'r' : $flipped .='\u0279';
                            break;
                case 't' : $flipped .='\u0287';
                            break;
                case 'v' : $flipped .='\u028C';
                            break;
                case 'w' : $flipped .='\u028D';
                            break;
                case 'y' : $flipped .='\u028E';
                            break;
                case '.' : $flipped .='\u02D9';
                            break;
                case '[' : $flipped .=']';
                            break;
                case '(' : $flipped .=')';
                            break;
                case '{' : $flipped .='}';
                            break;
                case '?' : $flipped .='\u00BF';
                            break;
                case '!' : $flipped .='\u00A1';
                            break;
                case "\'" : $flipped .=',';
                            break;
                case '<' : $flipped .='>';
                            break;
                case '_' : $flipped .='\u203E';
                            break;
                case ';' : $flipped .='\u061B';
                            break;
                case '\u203F' : $flipped .='\u2040';
                            break;
                case '\u2045' : $flipped .='\u2046';
                            break;
                case '\u2234' : $flipped .='\u2235';
                            break;
                case '\r' : $flipped .='\n';
                            break;
                case ' ' : $flipped .=''; 
                            break;  
            }
    }

return $flipped;
}

echo flip("abcdefghijklmnopqrst");
?>

Thank you!

  • 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-14T04:51:33+00:00Added an answer on June 14, 2026 at 4:51 am

    change them to htmlentity like,

    case 'a': $flipped .= '&#592;';
    break;
    case 'b' : $flipped .='q';
    break;
    case 'c' : $flipped .='&#596;';
    break; etc....
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a method that does the following: Replace every occurrence of
I am trying to replace a large string in groovy. But can't get it
Lets say I'm trying to replace every A character with a B, inside two
I'm trying to make a basic replace code that replaces the match every time.
I am trying to replace the nth occurrence of a character or string regardless
I am trying to do transliteration where I need to replace every source character
I am trying to find every occurrence of an ASCII character in a string
Hi guys thanks for pay attention to this. Well im trying to replace every
im trying to create a script that opens a file and replace every 'hola'
I'm trying to find every instance of @username in comment text and replace it

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.