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. 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']} 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 [' ']? 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>"; ?> 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. Link to comment https://forums.phpfreaks.com/topic/86331-variable-in-array-question/#findComment-441734 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.