Page 1 of 1

Formatting a value retirved from database

Posted: Tue Nov 18, 2008 3:12 pm
by anujphp
hello
I have stored a paragraph in mysql database and when i try to retrive it and sisplay i want to format the paragrapg...
The paragraph is like this

1.some text 2.again some text 3.again some text 4.again some text


I want my output to be like this

1.some text
2.again some text
3.again some text
4.again some text

and so on

i am able to retrive the praragrapg in a variable like the variable is $paragraph
now i dont no how to cut the line after a number and point(fullstop)

Please Help me guys...its urgent
THANKING YOU IN ADVANCE

Re: Formatting a value retirved from database

Posted: Tue Nov 18, 2008 3:36 pm
by Hannes2k
Hi,
you can use preg_replace.

Reg-Ex: "([0-9]+)." replace with "<br />$1."

Re: Formatting a value retirved from database

Posted: Tue Nov 18, 2008 3:50 pm
by Eran
Is it possible this text originated in a textarea? if that's the case it has line-breaks which can be converted to html breaks using nl2br().

Re: Formatting a value retirved from database

Posted: Tue Nov 18, 2008 9:41 pm
by anujphp
yes the text originate in text area,how to convert line break into html code,cam you please give me the code

Re: Formatting a value retirved from database

Posted: Tue Nov 18, 2008 10:41 pm
by anujphp
THANKS A LOT


I am able to solve the issue.thanks once again.
As suggested by you i have used the function nl2br and able to get the result as i wanted.