I need to create 2 variables, and 34 of each of them.
$found1 > $found34
$name1 > $name34
I tried creating them in a for loop, but they are not available outside the loop.
is there a simple way to create these globally in a php page ?
Here is the test I tried
for($i = 0; $i <= 33; $i++) {
$found[$i] = "David".$i;
}
echo "Found 3: " . $found3;
You may need to use extract:
for($i = 0; $i <= 33; $i++) {
$found["found".$i] = "David".$i;
}
extract($found);
echo "Found 3: " . $found3;
Result:
Found 3: David3
So you need the key to be found.$i
to get found1
, found2
,...
Remember: You end up creating too many variables!! It is better to use array as array
It just takes two characters to call $found3
as $found[3]