2012-05-08 05:29
浏览 10


have a help file which i have created in Notepad++ with the following syntax


<!-- Heading of the Issue/Solution

// it may contain PHP Code or Mysql Queries or General Description

    // Code that fixed the issue/ Solution to a problem

Some general Description

I used the above format because in Notepad++ if i press "ALT + 0"

it display as

<!-- Heading of issue 1
<!-- Heading of issue 2

so that it helps in finding a solution to a problem reading the heading. But the help file has increased in size and contains hundreds of issues

So i am trying to load the file to database and use PHP to search for the issues/solutions

My Database Schema would be like

Create table issues
 id int auto_increment primary key,
 header nvarchar(100),
 content text

My Question is how do i load the particular file to database?

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • duanmei1894 2012-05-08 05:44
    // Read the file into a php variable:
    $filecontents = file_get_contents ("PHP_Help.html");
    // explode the string into individual records:
    $records = explode ( "<!--" , $filecontents );
    // work through the array of records:
    foreach($records as $record) {
        // find your first linefeed
        $headingend = strpos($record, chr(13) );
        // get the heading
        $heading = substr($record, 0, $headingend);
        // and the content
        $content = substr($record, $headingend);
        // write to the database...
    打赏 评论

相关推荐 更多相似问题