Stating Variables in external .txt files
| From: | scott | Date: | Thu, 24 Aug 2000 00:27:55 +0000 |
| Subject: | Stating Variables in external .txt files | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-13268@lists.php.net to get a copy of this message | ||
Is there any way to store more than variable in an external .txt variable. I
am new to PHP so this may be a very stupid question. However, I am learning
and fast.
The reason that I don't think that it is possible becuase of the way I am
reading in text files. At the moment each text file is read and then turned
into a variable.
The Code:
for ($i = 1; $i < $numItems; $i++) {
$iCurr = "$i.txt";
if (!$text=fopen("$iCurr", "r"))
echo ("file $iCurr does not exist".BR);
} elseif ($numItems) {
$newsItem = fread($text, 100);
${"newsItem".$i} = "$newsItem";
}
}
Just doing a simple for loop to continue looping until $i (which is
incremented each loop) is == $numItems.
I am reading in text files and setting them as the variable $newsItem ---
$newsItem = fread($text, 100); --- So it is just reading up to 100 chars of
the file. But if I inlcude for example --- $foo = "BAR"; --- then PHP wont
recognize this as its own var, but rather just a string in $newsItem (which
changes value each loop).
Is there anyway I can read in a .txt file and state something like --- $foo
= "BAR"; --- and have PHP interpret that as a variable.
Hope So.
Thanks for anyhelp.
Scott.