954,604 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Text formatting With PHP

Is it possible to format text with php as in whenever php sees ~ in text it would put
.
I am not sure if it is possible as i am new to php.

ashneet
Junior Poster
147 posts since Jun 2005
Reputation Points: 10
Solved Threads: 1
 

Formatting in PHP is quite simple, really.

heres an example of echoing some bold text:
[PHP] <?php
echo "Hello World";
?>[/PHP]
Also, newlines in PHP (ie
) are output like this:
[PHP]echo "Hello\nWorld"[/PHP]
The above would make:
[indent]Hello
World
[/indent]I hope this has helped you :D
Cheers

Electrohead
Junior Poster
150 posts since May 2005
Reputation Points: 10
Solved Threads: 2
 

I know how to do that too what i want is for the php to look into what is posted out of DB and find any tildas (~) and put
flag there instead of (~).
Now you you understand what i mean as i have no other way of explaing the problem as i am new to php

ashneet
Junior Poster
147 posts since Jun 2005
Reputation Points: 10
Solved Threads: 1
 

Well, if you have a string, and you want to replace parts of that string with another string, maybe you should search for a PHP command to replace strings.

str_replace()

Troy
Posting Whiz
362 posts since Jun 2005
Reputation Points: 36
Solved Threads: 6
 

You might be better to save the actual html to the database, or bbcode. There are plenty of scripts to help automate that. Let us know if you need any pointers.

Sarah

sarahk
Junior Poster
144 posts since Apr 2005
Reputation Points: 10
Solved Threads: 1
 

Hi,

What kind of script are you talking about as i am unsure what you mean about scripts.

THX

ashneet
Junior Poster
147 posts since Jun 2005
Reputation Points: 10
Solved Threads: 1
 

something like this: http://www.isolated-designs.net/core/projects/27/php-bbcode-functions

but it all depends on where the text is coming from and where it's going to.

The other way to get nicely formatted text is to use an htmlarea type of tool. There is a site acting as a directory of them at http://www.htmlarea.com/

S

sarahk
Junior Poster
144 posts since Apr 2005
Reputation Points: 10
Solved Threads: 1
 

Thanks a lot that is exactly what i am looking for...

ashneet
Junior Poster
147 posts since Jun 2005
Reputation Points: 10
Solved Threads: 1
 

sorry about that! didn't quite get what you meant!

hope you got it sorted!

Electrohead
Junior Poster
150 posts since May 2005
Reputation Points: 10
Solved Threads: 2
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You