Jump to content

cedricpatrick

New Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by cedricpatrick

  1. Hello, I am a PHP biginner. I would be grateful if you could help with the issue below. I have created three input dynamic variables in a separate php file using a For lopp. <?php For ($i=1; $i<=31; $i++) { echo '<div class="row">'; echo '<div class="col span-1-of-4">'; //Dates en français $jour = $jour + 1; $dateTest = $annee . "-" . $mois . "-" . $jour; $date = date_create("$annee-$mois-$jour"); echo '<input name="workday[]" id="workday[]" class="donnee-pointage1" value="'; echo date_format($date, 'd/m/Y'); echo '">'; echo " "; echo '</div>'; echo '<div class="col span-1-of-4">'; echo '<input type="time" name="startTime[]" id="startTime[]">'; echo '</div>'; echo '<div class="col span-1-of-4">'; echo '<input type="time" name="endTime[]" id="endTime[]">'; echo '</div>'; echo '</div>'; } ?> The form works well. In another PHP I would like to use the three arrays workday[], startTime[] and endTime to calculate the duration between startTime and endTime for each working day. I can access the different arrays using Foreach like below but I don't see how to combine thos arrays in order to be able to calculate the duration between two data that are in diffrent arrays. Is it possible to make calculations using variables stored in different arrays ? If so could you help me understand how ? <?php if (isset($_POST['workday'])) { foreach ($_POST['workday'] as $i => $workday) { echo $workday . "<br>; } } if (isset($_POST['startTime'])) { foreach ($_POST['startTime'] as $i => $startTime) { echo $startTime. "<br>; } } if (isset($_POST['endTime'])) { foreach ($_POST['endTime'] as $i => $endTime) { echo $endTime. "<br>; } } } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.