PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I've read through the variable variables section on PHP.net but it doesn't seem to explain combining preset variable names with dynamic variables names.
If you are just setting $G1 to 1 what was the point in the previous two operations.
I've read through the variable variables section on PHP.net but it doesn't seem to explain combining preset variable names with dynamic variables names.
I'm not entirely sure what you are trying to do there but something like this might help you:
Kieran Huggins wrote:I would just use a multidimensional array: $g['10']['c'] and $g['10']['n'] and $g['4']['c']....
also, by setting $Gx = 1 in your example, you're writing over the array you just created... not sure if that's intended.
I've taken this approach and it seems to work honky dory.
I was trying to use a preset variable name ($G) and then add a dynamic part onto the end of that preset variable. So if in a loop $i was 4 then I wanted to access the variable $G4 and if $i was 9 then to access variable $G9. It doesn't seem possible to do though and I'm not sure why I didn't use a multi-dimensional to start with. Could be because I've had a glass of orange juice instead of a strong coffee this morning.