cheechm Posted August 14, 2008 Share Posted August 14, 2008 Hi, I have this loop: $i=1; while($i<=3) { //insert stuff here $i++; } I want to make from the variable $i, a new variable. Literally by the end I want: $field1 $field2 $field3 where 1,2,3 have come from $i. Hope that makes sense. Thanks Link to comment https://forums.phpfreaks.com/topic/119748-solved-variable-in-a-variable/ Share on other sites More sharing options...
trq Posted August 14, 2008 Share Posted August 14, 2008 Do you plan on getting a value for these variables from somewhere? Lets use 'foo' as an example. $i=1; while ($i<=3) { ${'field' . $i} = 'foo'; $i++; } Link to comment https://forums.phpfreaks.com/topic/119748-solved-variable-in-a-variable/#findComment-616973 Share on other sites More sharing options...
cheechm Posted August 14, 2008 Author Share Posted August 14, 2008 Yes I will eventually. Thanks Link to comment https://forums.phpfreaks.com/topic/119748-solved-variable-in-a-variable/#findComment-616979 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.