Jump to content

Archived

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

Dragy

Text flip code

Recommended Posts

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  !

Share this post


Link to post
Share on other sites
something like!

[code]<?php

$eol = "\r\n";

$text = 'blah

blah

blah

';


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

echo $text;

?>[/code]


me!

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

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.