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 8552443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:25:30+00:00 2026-06-11T14:25:30+00:00

I am very new to PHP, and need some suggestions on a good starting

  • 0

I am very new to PHP, and need some suggestions on a good starting point for a project I am working on.

I have a website and a newsletter, both of which are composed of news article summaries (the website is similar to older versions of Digg, but with no user submissions). A word document is drafted in the format of:

Category

Article title

News article summary

Link to website article is found on

Once the word document is populated with all of the article summaries, I would like to be able to copy all of the text from the document, paste it into a single textarea field in an html form, and have PHP somehow pick out the separate story summaries and store them in a database, so they can later be pulled onto the website.

The only way I can think to do this is to add descriptive tags in the word document such as:

<begin_category>Category<end_category>

<begin_title>Article Title<end_title>

and so on, and then have php recognize these tags (preg_match?) and pull the information from them. My questions then are, what is the best way to go about programming this? Are there any concepts I should be researching? How do I tell PHP to look for these tags and pull everything in between them? Is this a terrible way to go about this? Am I better off just having a form that has different fields for all of the items (category, title, summary, link) and submit each summary one by one?

The only reason I want to be able to post the entire document and have it populate is to save time. The word document must be written up regardless for the newsletter.

Any direction would be much appreciated; things I should be googling, articles I should be reading, etc.

  • 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-11T14:25:31+00:00Added an answer on June 11, 2026 at 2:25 pm

    The first thing I would consider is that pasted word can be very messy if you get the encoding wrong, so if you have any issues, make sure your html form and php file (might be one and the same) and the database storage have a matching encoding.

    For example save the php source in utf8, make sure to use an appropriate unicode scheme for the data storage and include the following header in your HTML :

    <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
    

    If you are always in control of the input this is not such an issue. You can often clear word mess by pasting into notepad, and then from notepad to your form. Better would be to use notepad so are using plain asci txt. but if you get the encoding matched across the board you should be good to go.

    You could use tags as you have suggested and parse the content out with a method such as the following:

     /**
    * parses $string for blocks of content appearing between $starttag and $endtag
    * Will parse all matching blocks and return as array.
    * 
    * @return Array The blocks of content parsed from $string
    * 
    * @param string $string   This is the content to be parsed, for example this could be the HTML from the buffer
    * @param string $starttag This is the start tag, the beginning of a returnable content block i.e <!--customtag  or <img
    * @param string $endtag The end of block of content.
    */
    function ParseBlocks($string, $starttag, $endtag)
    {
        $pattern = "/".preg_quote($starttag).'(.*?)'.preg_quote($endtag)."/"; 
        if(preg_match_all($pattern, $string, $matches, PREG_PATTERN_ORDER) === false)
            $this->WriteError(preg_last_error());
        return $matches[1];
    } 
    

    You could use such a function in the following way, but it presumes that the input is even and each entry will have all required sections, as you expecting as output 4 arrays each with the same length:

    $categories = ParseBlocks($postedContent,"<!category>","</category");
    $titles = ParseBlocks($postedContent,"<!title>","</title");
    $summaries = ParseBlocks($postedContent,"<!summary>","</summary");
    $links = ParseBlocks($postedContent,"<!link>","</link");
    

    You would then be able to access the contents to push to a database :

    $itemCount = count($categories);
    for($i =0; $i < $itemCount; $i++)
    {//some db insert function -  this is made up, but should give the idea.
      db_execute('insert into t_table values (?,?,?,?)'
          ,array($categories[$i], $titles[$i], $summaries[$i], $links[$i]);
    }
    

    As an alterntive to all of that, you might consider posting the actual file (remove the copy and paste) and parsing that server side. Or is it possible to scrape the data from your website?

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

Sidebar

Related Questions

I need some help. I'm very new to cURL. I got a script working
I'm very new to MySQL so I need some help please, I have a
I have quite some experience with php, but I am very new to using
I'm very new to Python, but I need to migrate a project from PHP
I'm very new to PHP and I have a small task of displaying a
I am VERY new to PHP, I'm currently working on a service, part which
I'm very new to php. I found some CMS like code for east text
I'm new to PHP, so I need some guidance as to which would be
I'm very new in programming. I'm writing a PHP application that need to execute
in my website I have some pages structured in this way: www.mysite.com/x/y.php?query=z I wrote

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.