Jump to content

Archived

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

Mouse

reversing text...

Recommended Posts

Hello… quick question, I need to know how to build a simple form that I put text into and it will spit it out reversed… i.e. I put in “Hello!” It will return “!olleH” any answers?

Mouse

Share this post


Link to post
Share on other sites
Use the function [url=http://www.php.net/strrev]strrev()[/url]

Ken

Share this post


Link to post
Share on other sites
another unknown function... many thanks...

Share this post


Link to post
Share on other sites
I recommend looking through the documentation on php.net. You don't have to memorize it, but if you look at the names of the functions, you might be able to figure out which function you need without asking.

Ken

Share this post


Link to post
Share on other sites
I have been using a language filter to add tooltips (informative mousovers) to my site but I had an issue with the filter finding keywords within the added mousover script… erm… a little clearer? Well if I used “Duck” as a keyword and then I put the phrase “Donald Duck” into the mouesover explanation the function died so I tried this…

I reversed all the content with
[code]
<?php
$outputtext = strrev($inputtext);
echo $outputtext
?>
[/code]

So “Donald ‘Fauntleroy’ Duck He usually wears a sailor shirt and cap — but no pants (except when he goes swimming). Although usually easygoing, Donald's most famous trait is his short and often explosive temper. Donald's famous voice, and semi-intelligible is one of the most identifiable voices in the world”

Became

“dlrow eht ni seciov elbaifitnedi tsom eht fo eno si elbigilletni-imes dna ,eciov suomaf sdlanoD .repmet evisolpxe netfo dna trohs sih si tiart suomaf tsom sdlanoD ,gniogysae yllausu hguohtlA .)gnimmiws seog eh nehw tpecxe( stnap on tub — pac dna trihs rolias a sraew yllausu eH kcuD yoreltnuaF dlanoD”

then I used a little CSS to put it right again…

[code]
.backwards {unicode-bidi:bidi-override; direction: rtl;}
[/code]

Well I thought so… but have a look for yourself what happens… http://mouse.nodstrum.com/backwards.php

Any ideas??? Please

Mouse

Share this post


Link to post
Share on other sites
It's the CSS code that is doing that. Those CSS properties are meant to display languages that should go from right-to-left & bottom-to-top.

I think you need to find another approach. Perhaps serializing the value?

Share this post


Link to post
Share on other sites
just strrev the backwards text....
and yes, unicode-bidi is used for languages that read right to left.  nothing to do with backwards text.

Share this post


Link to post
Share on other sites
Oh well seemed like such a good idea... at the time!

many thanks

Mouse

Share this post


Link to post
Share on other sites
[quote author=mjdamato link=topic=112850.msg458319#msg458319 date=1161903613]
I think you need to find another approach. Perhaps serializing the value?
[/quote]
so what were you thinking? i didn't get what you meant...

Share this post


Link to post
Share on other sites
mouse you sure that the .js file your using issint gone dead i think a re install ha.

Share this post


Link to post
Share on other sites
thinking about it, now that i am at work and away from my PHP machine would

[code]
<?php echo strrev (txet yM); ?> work in the JavaScript/CSS tag???
[/code]

Mouse

Share this post


Link to post
Share on other sites
[quote author=redarrow link=topic=112850.msg458457#msg458457 date=1161932807]
mouse you sure that the .js file your using issint gone dead i think a re install ha.
[/quote]Works for me...

Share this post


Link to post
Share on other sites

×

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.