Jump to content


Photo

reversing text...


  • Please log in to reply
13 replies to this topic

#1 Mouse

Mouse
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts
  • LocationToo Close to LONDON

Posted 26 October 2006 - 07:18 PM

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


#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 26 October 2006 - 07:27 PM

Use the function strrev()

Ken

#3 Mouse

Mouse
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts
  • LocationToo Close to LONDON

Posted 26 October 2006 - 07:28 PM

another unknown function... many thanks...

#4 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 26 October 2006 - 07:35 PM

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

#5 Mouse

Mouse
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts
  • LocationToo Close to LONDON

Posted 26 October 2006 - 08:30 PM

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
<?php
$outputtext = strrev($inputtext);
echo $outputtext
?>

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…

.backwards {unicode-bidi:bidi-override; direction: rtl;}

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

Any ideas??? Please

Mouse


#6 Psycho

Psycho
  • Moderators
  • Move along, nothing to see here
  • 11,892 posts
  • LocationCanada

Posted 26 October 2006 - 11:00 PM

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?
The quality of the responses received is directly proportional to the quality of the question asked.

I do not always test the code I provide, so there may be some syntax errors. In 99% of all cases I found the solution to your problem here: http://www.php.net

#7 Skatecrazy1

Skatecrazy1
  • Members
  • PipPipPip
  • Advanced Member
  • 126 posts
  • LocationSouthern California

Posted 27 October 2006 - 12:56 AM

just strrev the backwards text....
and yes, unicode-bidi is used for languages that read right to left.  nothing to do with backwards text.
fuck it or fight it

#8 Mouse

Mouse
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts
  • LocationToo Close to LONDON

Posted 27 October 2006 - 06:56 AM

Oh well seemed like such a good idea... at the time!

many thanks

Mouse

#9 Mouse

Mouse
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts
  • LocationToo Close to LONDON

Posted 27 October 2006 - 06:58 AM

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

so what were you thinking? i didn't get what you meant...

#10 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 27 October 2006 - 07:06 AM

mouse you sure that the .js file your using issint gone dead i think a re install ha.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#11 Mouse

Mouse
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts
  • LocationToo Close to LONDON

Posted 27 October 2006 - 08:05 AM

thinking about it, now that i am at work and away from my PHP machine would

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

Mouse

#12 Mouse

Mouse
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts
  • LocationToo Close to LONDON

Posted 27 October 2006 - 08:07 AM

mouse you sure that the .js file your using issint gone dead i think a re install ha.

Works for me...

#13 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 27 October 2006 - 08:12 AM

This works fine
<?php echo strrev ("txet yM"); ?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#14 Mouse

Mouse
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts
  • LocationToo Close to LONDON

Posted 27 October 2006 - 08:21 AM

many thanks




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users