bschultz Posted November 13, 2013 Share Posted November 13, 2013 I'm have a hard time figuring out variable variables. if (${$pos_$i} == '1234') So, the $i is in a loop... The full variables are $pos_1, $pos_2, $pos_3 etc. How can get this to work? The code above throws a Parse error: syntax error, unexpected T_VARIABLE in... error. Thanks! Link to comment https://forums.phpfreaks.com/topic/283868-variable-variables/ Share on other sites More sharing options...
bschultz Posted November 13, 2013 Author Share Posted November 13, 2013 Why is it you always find the right Google phrase AFTER you post the questions? ${'pos_' . $i} Link to comment https://forums.phpfreaks.com/topic/283868-variable-variables/#findComment-1458130 Share on other sites More sharing options...
AbraCadaver Posted November 13, 2013 Share Posted November 13, 2013 Did google tell you that there is rarely if EVER a good reason to use variable variables? Use an array: if ($pos[$i] == '1234') Post more code if you are still unsure. Link to comment https://forums.phpfreaks.com/topic/283868-variable-variables/#findComment-1458132 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.