How can I use loop (for, forEach, while etc.) to the following part of code. Here "tarray" is an array of 10 values. The part of the code :
$string = $tarray[0];
$datetime = strtotime($string);
$datetime1 = date("Y-m-d H:i:s", $datetime);
list($year, $month, $day, $hours, $minutes, $seconds) = explode('-', $datetime1);
$string = $tarray[1];
$datetimea = strtotime($stringa);
$datetime2 = date("Y-m-d H:i:s", $datetimea);
list($year, $month, $day, $hours, $minutes, $seconds) = explode('-', $datetime2);
I want to write this only once instead of declaring multiple variables.