yami007 Posted September 21, 2009 Share Posted September 21, 2009 this is my code <?php $q1 = 'hello'; $q2 = 'Hi'; $q3 = 'Hey'; $q4 = 'Bye'; $q5 = 'See you'; $i = 0; while ($i <= 4) { $i++; $ echo 'Greetings : '.$q.$i.'<br />'; } ?> what i want to is get the variable $i before getting the variable $q so that it would display something like : Greetings : hello Greetings : hi Greetings : hey ... how ?? Link to comment https://forums.phpfreaks.com/topic/175028-solved-how-would-i-do-this/ Share on other sites More sharing options...
PFMaBiSmAd Posted September 21, 2009 Share Posted September 21, 2009 Use an array any time you have a set of related variables that you need to access - <?php $q[1] = 'hello'; $q[2] = 'Hi'; $q[3] = 'Hey'; $q[4] = 'Bye'; $q[5] = 'See you'; $i = 0; while ($i <= 4) { $i++; echo 'Greetings : '.$q[$i].'<br />'; } ?> Link to comment https://forums.phpfreaks.com/topic/175028-solved-how-would-i-do-this/#findComment-922426 Share on other sites More sharing options...
yami007 Posted September 21, 2009 Author Share Posted September 21, 2009 yeah thanks Link to comment https://forums.phpfreaks.com/topic/175028-solved-how-would-i-do-this/#findComment-922430 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.