OK, bassically I want to be able to grab an array value like :
$array[2];
But my script will grab the array position NOT by a static number but from a variable that increments :
i.e
$count=4;
while ($count != 0) {
$array[$count];
$count++;
};
But this DOES NOT work :mad:
For more info -
I am using JpGraph to create a line graph from data in a coma seperated file. Now it's all set up perfectly and is exploding the file and putting each line of data into a ydata# variable depending on how many lines.
The problem is that the call to plot the line :
$lineplot->SetColor("red");
$lineplot->SetWeight(2);
Is looping round and creating all red lines.
I need to create each lineplot of a different color!
So I created an array :
and then :
$colors = array(red,blue,black,green,orange,pink,brown);
$count = 4;
while ($count != 0) {
${"lineplot$count"}->SetColor($colors[$count]); << [b]Doesn't work[/b]
${"lineplot$count"}->SetWeight(2);
$count4--;
};
But PHP/JpGraph says "invalid colour" :eek:
Now if i do :
$count = 4;
while ($count != 0) {
${"lineplot$count"}->SetColor($colors[2]);[b]Works[/b]
${"lineplot$count"}->SetWeight(2);
$count--;
};
I get all the lines in black so the array IS WORKING, but i CANNOT reference the array through a variable!
So what syntax do i need to get PHP to take the literal value of the variable?
I hope you can understand what I'm trying to achieve, and that you can help me out. Thanks!
######Edit
I tried -
$colors[] = $count;
and
next( $colors );
But that didn't work, and have used the search function but not found a similar thread!
Surely some-one must need to reference an array with a variable?