entering text into db and spliting it up

Posted on 2009-02-16
Last Modified: 2013-12-12
if i have a textbox and in it i have


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?
Question by:runnerjp
    LVL 34

    Accepted Solution

    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.

    Author Comment

    how would i seperate them before into the db?
    LVL 107

    Assisted Solution

    by:Ray Paseur
    To break the lines up correctly before putting the information into the data base, look at nl2br() and see especially this note:

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

    HTH, ~Ray

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
    Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now