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.

Formatting in PHP is quite simple, really.

heres an example of echoing some bold text:

<?php
echo "<b>Hello World</b>";
?>

Also, newlines in PHP (ie <br/>) are output like this:

echo "Hello\nWorld"

The above would make:

Hello
World
I hope this has helped you :D
Cheers

Comments
Post does not apply to the question.

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

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()

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

Hi,

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

THX

This article has been dead for over six months. Start a new discussion instead.