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.

Recommended Answers

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

Jump to Post

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

Jump to Post

All 8 Replies

Member Avatar

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

commented: Post does not apply to the question. +0

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

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

Member Avatar

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

hope you got it sorted!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.