Split Text read from a Text file into paragraphs using php
How to read/convert the data read from a text file into paragraphs and display them paragraph wise. I did a lot of searching about this issue to achieve success. So it thought of just publishing that part of how to split the data paragraph wise and then displaying it.
preg_match_all(‘~ <p>.*?</p>~s’, $rawdata,$m);
$paragraphs = $m[0];
foreach($paragraphs as $p)
{ echo $p; }
Here $rawdata is the source in which the preg_replace will search for the pattern <p> </p> and the data between the paragraph tags will be given to $m(array)
$m[0] gives the first matches ie all the paragraphs in the data to $paragraphs(another array). Using the Loop we can now display Paragraphs one by one.
Note: This is my first time im explaining a script. Please excuse me. I’ll work out more to learn more n explaing more
Popularity: 4% [?]
hi, thanks for the code, it’s really help me with my project.
July 7th, 2009 at 12:44 am
thaank you.. u helped me to write about me in ma website
February 21st, 2010 at 10:46 pm
wtc
September 11th, 2011 at 5:44 pm
http://fatcowwebhosting143.wordpress.com/2011/09/05/the-art-of-investing-income-when-in-college-on-a-shoestring/
September 11th, 2011 at 6:49 pm