Forum Moderators: coopster

Message Too Old, No Replies

Splitting String on nl2br

then inserting into an array

         

ukgimp

11:32 am on Apr 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Having a little bit of difficulty on this one. I have a feild in a db that has lin breaks

This works nicely:

$longdescription = mysql_result($sql,$i,"longdescription");
$longdescription = nl2br($longdescription);

However, what I would like to do is split the new line and explode it into an array. Perhaps I am missing something.

psudo code

$string = "my feild that includes line breaks";
$pieces = explode("nl2br($string);", $string);

some sort of loop
echo $pieces[0];
print "<hr>";
echo $pieces[1];

Cheers for any advice

Birdman

11:40 am on Apr 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Maybe try:

$arr = explode("\r\n",$string)

or

$arr = explode("\n",$string);

It should work for you that way.

Birdman

sidenote: I don't think you want to put the semicolon inside the explode function.

ukgimp

11:46 am on Apr 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



cheers, i will try those.

Re the ";"

I was getting deparate with trial and error lol