Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8713839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:26:39+00:00 2026-06-13T05:26:39+00:00

Can anyone assist in the following. I have a field notes inside a mysql

  • 0

Can anyone assist in the following. I have a field “notes” inside a mysql table but need to separate it to a new table.

The note is currently in this format:

Added by username1 on 22/10/2012 3:50pm

The note is here

Added by username2 on 20/10/2012 12:29pm

The note is here and so on

There’s 2 notes here as an example. How can I get this into an array thus:

[0] => Array(
        [0] username1
        [1] 22/10/2012 3:50pm
        [2] Note1
    )
[1] => Array(
        [0] username2
        [1] 20/10/2012 12:29pm
        [2] Note2
    )

I tried using preg_split but it only returns note if split by “Added by username on date-time” because I can’t use “Added by” on its own to split it as the note itself might contain “Added by”

What would be be the best way to do this?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T05:26:40+00:00Added an answer on June 13, 2026 at 5:26 am

    Try this

    // Get the data from the database
    $myData = $row['notes'];
    
    // Split this into an array
    $data = explode("\r\n", $myData);
    
    // $data has each line as an element of the array
    $key   = -1;
    $final = array();
    foreach ($data as $element)
    {
        // Check if this is the first row
        if (strpos($element, "Added by") > 0)
        {
            $key = $key + 1;
            // This is the first header row. Get the info from it
            $tmp   = str_replace("Added by", "", $element);
            $parts = explode(" on ", $tmp)
    
            // Add them to the final array
            // Username
            $final[$key][0] = trim($parts[0]);
            // Date
            $final[$key][1] = trim($parts[1]);
    
            // Initialize the note element
            $final[$key][2] = '';
        }
        else
        {
            // We don't have the 'Added On' so add this as a note.
            $final[$key][2] .= $element;
        }
    }
    

    This should give you the base to work on. You can also check for empty lines in the notes element $final[$key][2] .= $element;

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Greetings! Can anyone please kindly assist me finding a way around the following: load
I have seen the following thread but it's a bit beyond me... How can
Can anyone assist me with the following. I've configured spring authentication fine so -
Can anyone assist me in connecting via Management Studio using the hostname provided by
can anyone assist me in finding the proper formula for quad normalization ? using
Can anyone help - this is driving me mad. I am calling a mysql
bit stuck try to achieve something in Jquery and wondered if anyone can assist..
Can anyone assist me in getting a function to be called, in this example
Can anyone let me know how can we change the value of kendo combobox
Can anyone enlighten me to a way I can Highlight the content of an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.