galvin Posted May 27, 2009 Share Posted May 27, 2009 Can you have a variable INSIDE another variable? For example, if I do a loop where $i is a number and keeps increasing by 1, and for this example, say $i = 3, can I say.. $got$i = $counts['count']; And have that be seen as a variable named "$got3"? if so, is there a certain way to write that (i.e. do I need curly braces or quotes or anything?) Link to comment https://forums.phpfreaks.com/topic/159947-solved-variable-inside-a-variable/ Share on other sites More sharing options...
Axeia Posted May 27, 2009 Share Posted May 27, 2009 ${$got.$i} = $counts['count']; I think though I can't say I have much confidence in saying so as I only used it ONCE, ever.. and then decided it wasn't the way to do it and changed my code... Anyways this might be of help: useful info Link to comment https://forums.phpfreaks.com/topic/159947-solved-variable-inside-a-variable/#findComment-843587 Share on other sites More sharing options...
BobcatM Posted May 27, 2009 Share Posted May 27, 2009 Do not think you can do that. $got$i = $counts['count']; Try this: echo $got; echo $i; $got = $counts['count']; $i++; Link to comment https://forums.phpfreaks.com/topic/159947-solved-variable-inside-a-variable/#findComment-843588 Share on other sites More sharing options...
galvin Posted May 27, 2009 Author Share Posted May 27, 2009 That worked, axeia, thanks! Link to comment https://forums.phpfreaks.com/topic/159947-solved-variable-inside-a-variable/#findComment-843598 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.