Jump to content


Photo

Text flip code


  • Please log in to reply
4 replies to this topic

#1 Dragy

Dragy
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 06 October 2006 - 12:03 AM

Hi guys  ;)
I'm not very knowledgeable with PHP, altough I am editing scripts and fit them into my needs all the time. But right now I need a very specific piece of code, shouldn't be too long, but I have absolute no idea where to start.

I got a text variable, lets say $sometext = "blah"; Now what I wanna do is simply flip it, so the final result will be "halb". Now that is step one, but after that I think I'll also include some HTML code in that variable, something like $sometext = "blah <br> blah"; And I gotta flipthe text without flipping the <br>. I'm not sure how complicated it is, but I just need that piece of code and I can't find anything about it.

Thanks  !

#2 Zane

Zane
  • Administrators
  • Advanced Member
  • 4,134 posts

Posted 06 October 2006 - 12:04 AM

look at the strrev() function
http://php.net/strrev

btn_donate_SM.gif Want to thank me? Contribute to my PayPal piggy-bank
 

172938.png

#3 printf

printf
  • Staff Alumni
  • Advanced Member
  • 889 posts

Posted 06 October 2006 - 12:19 AM

something like!

<?php

$eol = "\r\n";

$text = 'blah

blah

blah

';


$text = implode ( $eol, array_map ( 'strrev', explode ( $eol, $text ) ) );

echo $text;

?>


me!

#4 Dragy

Dragy
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 06 October 2006 - 12:54 AM

Hi, thanks, the code works, but the post didn't show the < br > and that's what I meant by including HTML code without flipping it, so let's say I'll be able to do
"Hi,
blah blah blah" (by "Hi, < br > blah blah blah")
and not just "Hi, blah blah blah" in one single line



#5 Dragy

Dragy
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 06 October 2006 - 01:03 AM

OK, I got this working by using printf s code! I just changed the \r \n to <br> and it all worked :)
thank you guys




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users