Hello, I've isolated and simplified the part of my code that I'm having problems with. What I want here is for this script to fetch elements from an array file (a different file name on each line in "array.txt") and use these variables to fetch and display the corresponding texts.

=======================
$array1=file("array.txt");

while( list(,$description) = each($array1) ){include ($description . ".txt");}

So instead of getting a list of descriptions, I get a list like this:

Warning: Failed opening 'XXX1 .txt' for inclusion in X.php on line X

Warning: Failed opening 'XXX2 .txt' for inclusion in X.php on line X

Warning: Failed opening 'XXX3 .txt' for inclusion in X.php on line X

and so on... I've obviously used fake data "X" in my example but notice the space between the file name and ".txt" I wonder if this is part of the problem. In any case, if someone sees something that isn't right in my code above, your help would be much appreciated 🙂
Thanx

    try:
    <?
    $array1=file("array.txt");
    while( list(,$description) = each($array1) ){$include.="include($description . ".txt");\n"; }
    eval($include);
    ?>

      Excellent! It didnt work the first tiem but I added some back slashes in
      {$include.="include($description . \".txt\");\n"; }
      And it works fine 🙂

      Now to see if it works when I incoporate it back into the main script.
      Thanks

        Write a Reply...