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

  • Home
  • SEARCH
  • 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 7898501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:27:00+00:00 2026-06-03T08:27:00+00:00

I am aware that this: <?php $file2 = file(‘website/files/myfolder/file.html’); echo $file2[8]; echo $file2[9]; echo

  • 0

I am aware that this:

    <?php

$file2 = file('website/files/myfolder/file.html');

echo $file2[8];
echo $file2[9];
echo $file2[10];
echo $file2[11];


?>

would give me the contents on lines 8,9,10,11 in the file.html file, however I would like to do this for about 100 lines ranging from lines 23 to 116. How would I accomplish this without using the echo $file2[NUMBER]; one hundrend times?

Another way to explain what I am trying to do would be possibly if I could do this in php:

echo $file2[23-116];

obviously this will not work but that is the concept.

Thanks for your help!

  • 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-03T08:27:02+00:00Added an answer on June 3, 2026 at 8:27 am

    Use a loop like so

    $data = file('website/files/myfolder/file.html');
    for ($i = 23; $i <= 116; $i++) {
        echo $data[$i];
    }
    
    • http://php.net/manual/en/control-structures.for.php

    Or you could splice the data:

    $data = file('website/files/myfolder/file.html');
    echo implode(PHP_EOL, array_splice($data, 23, 116 - 23));
    
    • http://php.net/manual/en/function.array-splice.php
    • http://php.net/manual/en/function.implode.php
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I aware that this will be a less programming question, but still... How can
I'm aware that you can do this: public ActionResult DoSomething([Bind(Exclude = CreationDate)] Item item)
I'm aware that MD5 has had some collisions but this is more of a
Let me preface this by saying that I'm well aware that running user supplied
In the answer to this question ovanes states: Please be aware that boost::lexical_cast is
My project doesn't seem to be aware of this new constant that's apparently auto-generated
In this question , I was made aware of glob()'s GLOB_BRACE option that allows
So, examining this directory structure /include_one.php /include_two.php /directory/main_file.php Assume that I am in /directory/main_file.php
i have a script that calls a php file and gets an JSON object
I have a PHP app that uses a $_GET parameter to select JS/CSS files

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.