943,879 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 30390
  • PHP RSS
Aug 2nd, 2005
0

Text formatting With PHP

Expand Post »
Is it possible to format text with php as in whenever php sees ~ in text it would put <br>.
I am not sure if it is possible as i am new to php.
Similar Threads
Reputation Points: 10
Solved Threads: 1
Junior Poster
ashneet is offline Offline
147 posts
since Jun 2005
Aug 2nd, 2005
-1

Re: Text formatting With PHP

Formatting in PHP is quite simple, really.

heres an example of echoing some bold text:
[PHP] <?php
echo "<b>Hello World</b>";
?>[/PHP]
Also, newlines in PHP (ie <br/>) are output like this:
[PHP]echo "Hello\nWorld"[/PHP]
The above would make:
Hello
World
I hope this has helped you
Cheers
Reputation Points: 10
Solved Threads: 2
Junior Poster
Electrohead is offline Offline
149 posts
since May 2005
Aug 2nd, 2005
0

Re: Text formatting With PHP

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 <br> 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
Reputation Points: 10
Solved Threads: 1
Junior Poster
ashneet is offline Offline
147 posts
since Jun 2005
Aug 3rd, 2005
0

Re: Text formatting With PHP

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()
Reputation Points: 36
Solved Threads: 6
Posting Whiz
Troy is offline Offline
354 posts
since Jun 2005
Aug 3rd, 2005
0

Re: Text formatting With PHP

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
Reputation Points: 10
Solved Threads: 1
Junior Poster
sarahk is offline Offline
138 posts
since Apr 2005
Aug 3rd, 2005
0

Re: Text formatting With PHP

Hi,

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

THX
Reputation Points: 10
Solved Threads: 1
Junior Poster
ashneet is offline Offline
147 posts
since Jun 2005
Aug 3rd, 2005
0

Re: Text formatting With PHP

something like this: http://www.isolated-designs.net/core...code-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
Reputation Points: 10
Solved Threads: 1
Junior Poster
sarahk is offline Offline
138 posts
since Apr 2005
Aug 3rd, 2005
0

Re: Text formatting With PHP

Thanks a lot that is exactly what i am looking for...
Reputation Points: 10
Solved Threads: 1
Junior Poster
ashneet is offline Offline
147 posts
since Jun 2005
Aug 3rd, 2005
0

Re: Text formatting With PHP

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

hope you got it sorted!
Reputation Points: 10
Solved Threads: 2
Junior Poster
Electrohead is offline Offline
149 posts
since May 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: On The Fly Edit
Next Thread in PHP Forum Timeline: PHP Tripod





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC