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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:44:51+00:00 2026-05-23T09:44:51+00:00

I have a homepage index.php. And I have two articles for example: article1.php and

  • 0

I have a homepage index.php. And I have two articles for example: article1.php and article2.php.

On my homepage I want to show previews of my two articles. But since these articles are too long, I only want to show 5 lines of an article (or 100 characters or another solution). After these first lines of the article it will end with “…” and these lines are linked to the actual article page; article1.php or article2.php

It should be a really simple thing I guess, showing some part of the text which I’m importing with the code “include”. By the way I’m not including a text file. It’s article1.php, so the code must ignore everything else like headers, photos vs. Must focus only the first lines of the text.

Any advice?

  • 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-05-23T09:44:51+00:00Added an answer on May 23, 2026 at 9:44 am

    If your article1.php file contains a whole page including HTML header and (apparently) some PHP code, this is really not an ideal starting point. You should store your articles (just the raw article text) in separate files. It’s then simple to reuse different parts of it in different places:

    article1.txt

    <p>Lorem ipsum.</p>
    <p>Foobar baz.</p>
    

    article1.php

    <html>
    <head>
        ...
    </head>
    <body>
       ...
       <?php include 'article1.txt'; ?>
       ...
    </body>
    

    index.php

    <html>
    <head>
        ...
    </head>
    <body>
       ...
       <?php
           $article1 = file_get_contents('article1.txt');
           echo substr(strip_tags($article1), 0, 100) . '...';
      ?>
      <a href="article1.php">Read more</a>
       ...
    </body>
    

    This way you can even automate the generation of links on your index.php by automatically going through all .txt files in the article directory and outputting those links. Storing articles in a database would make this even more flexible. Continuing along those lines you’re pretty much reinventing a CMS though, so you might want to consider using WordPress or some system like it.

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

Sidebar

Related Questions

I have a website on a server. The homepage is example.com/index.php . OK, I
I have already a site with a single homepage index.php which accepts 2 parameters
I'm currently facing a strange problem in PHP. I have two scripts, index.php which
I have 2 pages index.php and HomePage.php : when i click to sumbit from
I have a homepage.html and it refers to styles.css(makes a table). But I also
I have a custom module I made to show featured products on the homepage.
I want to use .htaccess file to return homepage (index.html) if direct access to
I have two sliders on my homepage, one is using a plugin (AnythingSlider), and
I have a index.php page in my root that simply reirects to what I
I'm new to codeigniter this is my case: I have a homepage with a

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.