I'm trying to split a string of text into paragraphs, getting the text input from a form. The assumption (instructions) are that the text is to be saved into a "notepad" file, no wordwrapping format, (the text is mostly articles that are free to republish.) The text is then to be copied and pasted from notepad into the php form, and when the submit button is clicked I am trying to split the text into paragraphs. The paragraphs are all double spaced (at least when they are copied into notepad they are double spaced).
I'm using the code below, it makes an array of the text, but every other line shows this for an element output:
"< [1] => > < "
This is the code I'm using:
PHP:--------------------------------------------------------------------------------
$string = $paragraph;
$string = str_replace("\n","<br/>",$string);
$string = preg_split("<br/>", $string); // string is an array containing paragraphs from $string
print_r ($string);
So basically I am getting an array return of:
PHP:--------------------------------------------------------------------------------
Array ( [0] =>Text from first paragraph. < [1] => > < [2] => >Text from second paragraph.< [3] => > < [4] => >Text from third paragraph.
and so on.....
I've tried about 10+ variations on this code, one variation works if I manually put the carriage returns in on the form itself, and one variation works properly if I put in some obscure delimiter like "qwert" (which would need to be typed into the beginning of every paragraph, not a very practical approach!)
I'm still pretty new and am totally confused now...
I'd appreciate any help!
Thanks
Bernadette