Spetter Posted August 18, 2008 Share Posted August 18, 2008 My database returns values in a structure so I can read the values as var_1 = $this->product->value_1; var_2 = $this->product->value_2; Now I want to do something like for ($counter = 1; $counter <= 5; $counter++) { var_$counter = $this->product->value_$counter; } I know that this is wrong, but is there a solution to do something simular? Link to comment https://forums.phpfreaks.com/topic/120189-variable-numbers/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 18, 2008 Share Posted August 18, 2008 You can use variable variables, but they are 3x slower than using an array. Any time you have a set of same type data you should use an array. Link to comment https://forums.phpfreaks.com/topic/120189-variable-numbers/#findComment-619164 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.