php to flip text?

Discussion in 'PHP' started by monkeyclap, Feb 25, 2010.

  1. #1
    does anyone know how to do it?

    i.e. as it were reflected horizontally

    thanks
     
    monkeyclap, Feb 25, 2010 IP
  2. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #2
    <?php
    $text = "here you go";
    ?>
    <font face="Arial Unicode MS">
    <script type="text/javascript">
    //Author: Frick
    var s2="<?php echo $text; ?>";
    s = s2.toLowerCase();
    while (s.indexOf("a") > -1)
    s = s.replace("a","\u0250");
    while (s.indexOf("b") > -1)
    s = s.replace("b","\u02A0");
    while (s.indexOf("c") > -1)
    s = s.replace("c","\u0254");
    while (s.indexOf("d") > -1)
    s = s.replace("d","\u0440");
    while (s.indexOf("e") > -1)
    s = s.replace("e","\u01DD");
    while (s.indexOf("f") > -1)
    s = s.replace("f","\u025F");
    while (s.indexOf("g") > -1)
    s = s.replace("g","\u0183");
    while (s.indexOf("h") > -1)
    s = s.replace("h","\u0265");
    while (s.indexOf("i") > -1)
    s = s.replace("i","\u0131");
    while (s.indexOf("j") > -1)
    s = s.replace("j","\u027E");
    while (s.indexOf("k") > -1)
    s = s.replace("k","\u029E");
    while (s.indexOf("m") > -1)
    s = s.replace("m","\u026F");
    while (s.indexOf("n") > -1)
    s = s.replace("n","?");
    while (s.indexOf("p") > -1)
    s = s.replace("p","d");
    while (s.indexOf("q") > -1)
    s = s.replace("q","b");
    while (s.indexOf("r") > -1)
    s = s.replace("r","\u0279");
    while (s.indexOf("t") > -1)
    s = s.replace("t","\u0287");
    while (s.indexOf("u") > -1)
    s = s.replace("u","\u043F");
    while (s.indexOf("v") > -1)
    s = s.replace("v","\u028C");
    while (s.indexOf("w") > -1)
    s = s.replace("w","\u028D");
    while (s.indexOf("y") > -1)
    s = s.replace("y","\u028E");
    while (s.indexOf("\n") > -1)
    s = s.replace("\n","\r");
    while (s.indexOf(".") > -1)
    s = s.replace(".","\u02D9");
    while (s.indexOf("?") > -1)
    s = s.replace("?","\u00BF");
    while (s.indexOf("!") > -1)
    s = s.replace("!","\u00A1");
    while (s.indexOf("_") > -1)
    s = s.replace("_","\u203E");
    while (s.indexOf(",") > -1)
    s = s.replace(",","`");
    while (s.indexOf("\u0027") > -1)
    s = s.replace("\u0027","\u0317");
    document.write(s);
    </script></font>
    PHP:
     
    danx10, Feb 25, 2010 IP
  3. insert

    insert Peon

    Messages:
    148
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    do you mean this?

    <?
    $word = "digitalpoint";
    for ($i = strlen($word); $i >= 0; $i--) echo $word[$i];
    ?>
    PHP:
     
    insert, Feb 25, 2010 IP
  4. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #4
    @insert

    He wants to flip the actual text not reverse, furthermore theirs already a function for what you posted -> strrev().
     
    danx10, Feb 25, 2010 IP
  5. monkeyclap

    monkeyclap Active Member

    Messages:
    836
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    85
    #5
    hey yeh, thanks for that.

    i've actually just started a thread about a strrev question: http://forums.digitalpoint.com/showthread.php?t=1711246

    any ideas?
     
    monkeyclap, Feb 25, 2010 IP
  6. insert

    insert Peon

    Messages:
    148
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    thanks for information, didn't know about strrev()...
     
    insert, Feb 25, 2010 IP
  7. HostingProvider

    HostingProvider Active Member

    Messages:
    1,480
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    95
    #7
    Just convert this JavaScript code to PHP and you should be good to go.
     
    HostingProvider, Feb 26, 2010 IP
  8. monkeyclap

    monkeyclap Active Member

    Messages:
    836
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    85
    #8
    sorry for being such a newbie, but how would i do this please?
     
    monkeyclap, Mar 3, 2010 IP
  9. Narrator

    Narrator Active Member

    Messages:
    392
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    80
    #9
    Here's the same thing in php:
    
    function upsideDown($var){
    $reverse=strtolower($var);
    $array=array("a" => "ɐ", "b" => "ʠ", "c" => "ɔ", "d" => "p", "e" => "ǝ", "f" => "ɟ", "g" => "ƃ", "h" => "ɥ", "i" => "ı", "j" => "ɾ", "k" => "ʞ", "m" => "ɯ", "n" => "u", "p" => "d", "q" => "b", "r" => "ɹ", "t" => "ʇ", "u" => "n", "v" => "ʌ", "w" => "ʍ", "y" => "ʎ", "\n" => "\r", "." => "˙", "?" => "¿", "!" => "¡", "_" => "‾", "," => "`", "'" => "̗");
    foreach($array as $key => $value){
    $var=str_replace("$key","$value",$var);
    }//end foreach
    return $var;
    }//end function
    
    PHP:
     
    Last edited: Mar 3, 2010
    Narrator, Mar 3, 2010 IP
  10. monkeyclap

    monkeyclap Active Member

    Messages:
    836
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    85
    #10
    thanks for that, but when i try to use the inverted text, i get question marks (in notepad++).

    this is what i'm seeing:

    i've also tried "\u0250" for "a" but then that just replaces it with "\u0250" and not the upside down character.

    any ideas? cheers

     
    monkeyclap, Mar 3, 2010 IP
  11. Narrator

    Narrator Active Member

    Messages:
    392
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    80
    #11
    Narrator, Mar 3, 2010 IP
  12. monkeyclap

    monkeyclap Active Member

    Messages:
    836
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    85
    #12
    that's great thanks, where did you get the ascii codes from as there are a few i wish to change. cheers again!
     
    monkeyclap, Mar 5, 2010 IP
  13. Narrator

    Narrator Active Member

    Messages:
    392
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    80
    #13
    Narrator, Mar 5, 2010 IP
  14. monkeyclap

    monkeyclap Active Member

    Messages:
    836
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    85
    #14
    just hit a little snag, because in the array, "d" is converted to "p" and "p" gets transformed into "d" that means all "d"s always remain as "d"s.

    is there a way to fix this. cheers once again, you have been really awesome!
     
    monkeyclap, Mar 5, 2010 IP
  15. monkeyclap

    monkeyclap Active Member

    Messages:
    836
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    85
    #15
    anyone able to help please?
     
    monkeyclap, Mar 9, 2010 IP
  16. TYPELiFE

    TYPELiFE Peon

    Messages:
    109
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #16
    You can also do this with plain CSS: friendlybit.com/css/reverse-text-with-css-32-very-special-hex-digits/
     
    TYPELiFE, Mar 9, 2010 IP