• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 171
  • Last Modified:

entering text into db and spliting it up

if i have a textbox and in it i have

data1
data2

so each text on a different line..


could i insert that into my db and then pull it out and explode it so i can echo "data1";  and echo "data2"  if that makes sence?
0
runnerjp
Asked:
runnerjp
2 Solutions
 
Terry WoodsIT GuruCommented:
Yes, something like this should work once you've got the data out of the db:

foreach(explode("\n",$textbox_contents) as $line) {
  print "$line<br \>\n";
}

If you ever want to look at a subset of the lines though, you would be best to separate them before putting them in the db.
0
 
runnerjpAuthor Commented:
how would i seperate them before into the db?
0
 
Ray PaseurCommented:
To break the lines up correctly before putting the information into the data base, look at nl2br() and see especially this note:
http://us3.php.net/manual/en/function.nl2br.php#78883

Then you could do something like explode('</p>,p>', $data);

HTH, ~Ray
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now