I am trying to state some variables.
I want to state a variable variable/ ie one part of the variable name is
constant and the other part is different.
The constant part of the variable name is $newsItem and the other part of
the variable name has to be the number of the loop ($ie)
Here is my 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);
echo (NL);
echo ("-- $newsItem -------- This was printed from $iCurr
(\$iCurr)".BR);
$newsItem.$i = "$newsItem"; ######### THIS IS THE PART WHERE I WANT TO
DO VAR VARS, BUT I KNOW THAT THIS SYNTAX IS WRONG ##########
} elseif ($numItems) {
// do nothing yet
}
// echo ("this is #$i var".BR); // Prints the number of $numItems
}
Whats happening here is I have loop that is controlled by $numItems this is
going to be 5. It loops until i = 5. It reads the info in from seperate text
files, '1.txt', '2.txt', '3.txt', '4.txt', '5.txt', etc.
I then want to set the variable $newsItem4 ($newsItem-4 is then determined
by the value of $i which increments each loop) to be $newsItem.
Can anyone help.
Thanks.
Scott.