Text Formatting

JavaScript and client side scripting.

Moderator: General Moderators

phppick
Forum Commoner
Posts: 57
Joined: Thu Aug 14, 2003 5:59 am

Post by phppick »

Hi vigge89

" i already posted how "

i am unable to Find where it is?? can you please help.

Thanks
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

Say

Code: Select all

їb]hello world!ї/b]
is supposed to become Hello World.

Step 1.
Create a form with a textarea.
Step 2.
Submit it to your php-script
Step 3.
In your php-script, use str_replace to replace

Code: Select all

"їb]Hello Worldї/b]"
with

Code: Select all

<b>Hello World!</b>
Step 4.
Do a test run.
Step 5.
Pat yourself on the back
Step 6.
Drink a cup of tea and smile.
Step 7.
Have a look at the GUI (graphical user interface) that this forum uses, look at the source code - it's all open source, find out how they do and use the bits you like, or all of it, or none at all.

Voila.

P.S.: And yes, if you read through the thread, all this was posted before.
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

actually, what version of PHP are u running? if its the newest(5) u can probably use stri_replace...

I never used the function cause i'm on an older version, but if its anything like str_replace, you'll be in the gold. and also another note.

atleast make an effort to find code and not want everyone to create it for you. :evil:
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

tim wrote:atleast make an effort to find code and not want everyone to create it for you. :evil:
If you're not too familiar with PHP it can be quite difficult to patch together something coherent from little odd bits of functions and manual-references. phppick wasn't asking for someone to write him a complete script, he simply did not understand how to make sense out of all the patchwork comments.
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

okay patrik.
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

blah

i'll get you started on the php side.

Code: Select all

<?php
$old = array('[ b ]', '[ /b ]', '[ b ]', '[ /b ]', '[ i ]', '[ /i ]', '[ i ]', '[ /i ]'); //note to not have spaces after the first [ n before the last ] n each statement (i had to do so cause without them, the board would now show them
$new = array('<b>', '</b>', '<b>', '</b>', '<i>', '</i>', '<i>', '</i>'); 
return str_replace($old, $new, $string); 
?>
seeing str_replace is case sensistive, thats why you will have to create the and statements. (like I said, stri_replace is case insensitive)
or if you feel really picky and have an older version, you can test your regular expression knowledge and create something using eregi_replace.

as for the textarea and the html side, i hope you can fend for yourself.
phppick
Forum Commoner
Posts: 57
Joined: Thu Aug 14, 2003 5:59 am

Thank You Very Much

Post by phppick »

Hi Guys,

Its working great.. Thank you all, patrik, tim etc..

Thanks
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

:)
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

welcome.
Post Reply