Skilled Illusionist
- Joined
- May 10, 2013
- Messages
- 321
- Reaction score
- 59
Hi, I have a problem, and I'd like some help.
In the include file are just some text references:
And so on...
How do I get the number after $x in the loop changed when the loopnumber changes.
Like "echo($x($i)[0]);" obviously doesn't work. I can't figure out the right way to do this.
Help is appreciated.
Thank you.
Solution:
PHP:
<?php include 'test.php';?>
<?php
for($i=1;$i<=10;$i++){
echo($x1[0]);
echo($x1[1]);
echo($x1[2]);
}
?>
In the include file are just some text references:
PHP:
<?php
$x1 = array();
$x1['0'] = "Hello 1.0";
$x1['1'] = "Hello 1.1";
$x1['2'] = "Hello 1.2";
$x2 = array();
$x2['0'] = "Hello 2.0";
$x2['1'] = "Hello 2.1";
$x2['2'] = "Hello 2.2";
?>
How do I get the number after $x in the loop changed when the loopnumber changes.
Like "echo($x($i)[0]);" obviously doesn't work. I can't figure out the right way to do this.
Help is appreciated.
Thank you.
Solution:
PHP:
<?php include 'test.php';?>
<?php
for($i=1;$i<=10;$i++){
echo(${'x'.$i}[0]);
echo(${'x'.$i}[1]);
echo(${'x'.$i}[2]);
}
?>
Last edited: