Jump to content

Include in for-loop


Phco

Recommended Posts

Hello,

I have some php-files containing variables with same names but different data.

$arr = array("file1.php", "file2.php", "file3.php");

I want to "get access" to these variables/data. One php-file at a time. This is what i am doing right now:

for($i=0; $i<sizeof($arr); $i++)
    include $arr[$i];

This does work in the first 2 php-files in the array but not on any other of them unless i change start-value of $i. Could you maybe help me solve this?

Link to comment
Share on other sites

What do you mean by "have same variables but different data"?  You do realize that one variable will replace any previously defined variable by the same name so having multiple uses of a single var name is not going to work?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.