TheFilmGod Posted January 16, 2008 Share Posted January 16, 2008 <?php echo "<a href=\"$link\">Period $class['$i']</a></li>"; ?> Will $class['$i'] parse correctly. Quote Link to comment https://forums.phpfreaks.com/topic/86331-variable-in-array-question/ Share on other sites More sharing options...
drummer101 Posted January 16, 2008 Share Posted January 16, 2008 no, it needs to be {$class['$i']} Quote Link to comment https://forums.phpfreaks.com/topic/86331-variable-in-array-question/#findComment-441106 Share on other sites More sharing options...
TheFilmGod Posted January 16, 2008 Author Share Posted January 16, 2008 no, it needs to be {$class['$i']} okay, that should help, but will $i parse right? $i is a variable and I want its value be parsed within [' ']? Quote Link to comment https://forums.phpfreaks.com/topic/86331-variable-in-array-question/#findComment-441107 Share on other sites More sharing options...
trq Posted January 16, 2008 Share Posted January 16, 2008 Then you dont need the single quotes at all. <?php echo "<a href=\"$link\">Period {$class[$i]}</a></li>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/86331-variable-in-array-question/#findComment-441119 Share on other sites More sharing options...
Nhoj Posted January 17, 2008 Share Posted January 17, 2008 Although thorpe is right, you should note that $i would not parse inside [' '] because any variables inside single quotes are not parsed by PHP. $class["$i"] should work $class['$i'] would not parse $class[$i] - the simplest method. Quote Link to comment https://forums.phpfreaks.com/topic/86331-variable-in-array-question/#findComment-441734 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.