Text formatting With PHP

Reply

Join Date: Jun 2005
Posts: 147
Reputation: ashneet is an unknown quantity at this point 
Solved Threads: 1
ashneet's Avatar
ashneet ashneet is offline Offline
Junior Poster

Text formatting With PHP

 
0
  #1
Aug 2nd, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 149
Reputation: Electrohead is an unknown quantity at this point 
Solved Threads: 1
Electrohead's Avatar
Electrohead Electrohead is offline Offline
Junior Poster

Re: Text formatting With PHP

 
-1
  #2
Aug 2nd, 2005
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
: :: Click here to join my website :: :
Brand new online community! Help my forum grow!
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 147
Reputation: ashneet is an unknown quantity at this point 
Solved Threads: 1
ashneet's Avatar
ashneet ashneet is offline Offline
Junior Poster

Re: Text formatting With PHP

 
0
  #3
Aug 2nd, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 354
Reputation: Troy is an unknown quantity at this point 
Solved Threads: 5
Troy's Avatar
Troy Troy is offline Offline
Posting Whiz

Re: Text formatting With PHP

 
0
  #4
Aug 3rd, 2005
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 Wolf is the author of SnippetEdit. "Website editing as easy as it gets." IX Web Hosting
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 138
Reputation: sarahk is an unknown quantity at this point 
Solved Threads: 1
sarahk's Avatar
sarahk sarahk is offline Offline
Junior Poster

Re: Text formatting With PHP

 
0
  #5
Aug 3rd, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 147
Reputation: ashneet is an unknown quantity at this point 
Solved Threads: 1
ashneet's Avatar
ashneet ashneet is offline Offline
Junior Poster

Re: Text formatting With PHP

 
0
  #6
Aug 3rd, 2005
Hi,

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

THX
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 138
Reputation: sarahk is an unknown quantity at this point 
Solved Threads: 1
sarahk's Avatar
sarahk sarahk is offline Offline
Junior Poster

Re: Text formatting With PHP

 
0
  #7
Aug 3rd, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 147
Reputation: ashneet is an unknown quantity at this point 
Solved Threads: 1
ashneet's Avatar
ashneet ashneet is offline Offline
Junior Poster

Re: Text formatting With PHP

 
0
  #8
Aug 3rd, 2005
Thanks a lot that is exactly what i am looking for...
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 149
Reputation: Electrohead is an unknown quantity at this point 
Solved Threads: 1
Electrohead's Avatar
Electrohead Electrohead is offline Offline
Junior Poster

Re: Text formatting With PHP

 
0
  #9
Aug 3rd, 2005
sorry about that! didn't quite get what you meant!

hope you got it sorted!
: :: Click here to join my website :: :
Brand new online community! Help my forum grow!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC