Creating new, smaller PHP files from 1 large PHP file

Hi,

This may not be possible but if I have a PHP page with say 3 sections of text can I create 3 separate files from the larger content? For example:

SECTION1
This is section 1 text. This is section 1 text. This is section 1 text. This is section 1 text. This is section 1 text. This is section 1 text. This is section 1 text. This is section 1 text. This is section 1 text. This is section 1 text. This is section 1 text. This is section 1 text. This is section 1 text. This is section 1 text. This is section 1 text. This is section 1 text. This is section 1 text. This is section 1 text. This is section 1 text. This is section 1 text. This is section 1 text.

SECTION2
This is section 2 text. This is section 2 text. This is section 2 text. This is section 2 text. This is section 2 text. This is section 2 text. This is section 2 text. This is section 2 text. This is section 2 text. This is section 2 text. This is section 2 text. This is section 2 text. This is section 2 text. This is section 2 text. This is section 2 text. This is section 2 text. This is section 2 text.

SECTION3
This is section 3 text. This is section 3 text. This is section 3 text. This is section 3 text. This is section 3 text. This is section 3 text. This is section 3 text. This is section 3 text. This is section 3 text. This is section 3 text. This is section 3 text. This is section 3 text. This is section 3 text. This is section 3 text. This is section 3 text.

Is there a way to say find SECTION1 and add content below until SECTION2 as a separate file. Likewise create another separate file for content below SECTION2 and above SECTION3?

Can this be done with PHP. Basically breakdown a large file into smaller files? The application I am using it for is a download of data that appears on one page. But I need the information broken down into separate files.

Thanks for your help.

Matt.

Sure, why not? Have each section reside in their own file and then include them via PHP?

I think you misunderstand - I want to go from 1 large file to small files. NOT the other way round.

That is exactly what @jeffreylees is talking about.

Put each section into separate file: section1.php, section2.php etc
and then combine them using include:

<?php 
    include "section1.php";
    include "section2.php";
    // and so on
1 Like

Perhaps to be more precise/clear up confusion: combine them AT RUNTIME with include.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.