0

Hey I have this piece of code here:

 <?php for($t=1; $t<=4;$t++ ){ 
<input name="total_hours" type="hidden" value="<?=$totalhoursweek.$t['Duration'];?>">
<?php };?>

How can I dynamically use the variable $t?

Result expected:

$totalhoursweek1['Duration'];
$totalhoursweek2['Duration'];
$totalhoursweek3['Duration'];
$totalhoursweek4['Duration'];
Sebastian Farham
  • 815
  • 2
  • 13
  • 27
  • http://php.net/manual/en/language.variables.variable.php – aynber Jun 20 '17 at 19:24
  • 2
    Also, almost any time you seem to need to use variable variables, there are probably some things in your code you need to rethink. – Don't Panic Jun 20 '17 at 19:27
  • Creating one variable like `$totalhoursweek[1]['Duration']`, etc. instead of four separate variables would be better, if you could do something like that. – Don't Panic Jun 20 '17 at 19:30
  • @Don'tPanic: well, that's just the way it is for now... I'm only doing this one time... It's probably bad practice but I can't go over the code as of today – Sebastian Farham Jun 20 '17 at 19:34
  • Sure, no offense intended. Just offering my unsolicited opinion. :) – Don't Panic Jun 20 '17 at 19:44

0 Answers0