Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
function everyTimeFrame($totalMinutes = 4, $lastSeconds = 16)
{
$time = [];
for ($i = 0; $i <= 59; $i++) {
for ($j = 0; $j <= $totalMinutes; $j++) {
$second = strlen($i) > 1 ? $i : "0{$i}";
if ($j == $totalMinutes && $i > $lastSeconds) {
break;
} else {
$time[$j][] = "{$j}:{$second}";
}
}
}
$time = array_map(function ($frames) {
return implode(', ', $frames);
}, $time);
return implode(', ', $time);
}
@awps
Copy link
Author

awps commented Nov 7, 2018

Define the minutes and seconds. The default values are 4 and 16. That's equal to 4:16 and will be transformed in:

0:00, 0:01, 0:02, 0:03, 0:04, 0:05, 0:06, 0:07, 0:08, 0:09, 0:10, 0:11, 0:12, 0:13, 0:14, 0:15, 0:16, 0:17, 0:18, 0:19, 0:20, 0:21, 0:22, 0:23, 0:24, 0:25, 0:26, 0:27, 0:28, 0:29, 0:30, 0:31, 0:32, 0:33, 0:34, 0:35, 0:36, 0:37, 0:38, 0:39, 0:40, 0:41, 0:42, 0:43, 0:44, 0:45, 0:46, 0:47, 0:48, 0:49, 0:50, 0:51, 0:52, 0:53, 0:54, 0:55, 0:56, 0:57, 0:58, 0:59, 1:00, 1:01, 1:02, 1:03, 1:04, 1:05, 1:06, 1:07, 1:08, 1:09, 1:10, 1:11, 1:12, 1:13, 1:14, 1:15, 1:16, 1:17, 1:18, 1:19, 1:20, 1:21, 1:22, 1:23, 1:24, 1:25, 1:26, 1:27, 1:28, 1:29, 1:30, 1:31, 1:32, 1:33, 1:34, 1:35, 1:36, 1:37, 1:38, 1:39, 1:40, 1:41, 1:42, 1:43, 1:44, 1:45, 1:46, 1:47, 1:48, 1:49, 1:50, 1:51, 1:52, 1:53, 1:54, 1:55, 1:56, 1:57, 1:58, 1:59, 2:00, 2:01, 2:02, 2:03, 2:04, 2:05, 2:06, 2:07, 2:08, 2:09, 2:10, 2:11, 2:12, 2:13, 2:14, 2:15, 2:16, 2:17, 2:18, 2:19, 2:20, 2:21, 2:22, 2:23, 2:24, 2:25, 2:26, 2:27, 2:28, 2:29, 2:30, 2:31, 2:32, 2:33, 2:34, 2:35, 2:36, 2:37, 2:38, 2:39, 2:40, 2:41, 2:42, 2:43, 2:44, 2:45, 2:46, 2:47, 2:48, 2:49, 2:50, 2:51, 2:52, 2:53, 2:54, 2:55, 2:56, 2:57, 2:58, 2:59, 3:00, 3:01, 3:02, 3:03, 3:04, 3:05, 3:06, 3:07, 3:08, 3:09, 3:10, 3:11, 3:12, 3:13, 3:14, 3:15, 3:16, 3:17, 3:18, 3:19, 3:20, 3:21, 3:22, 3:23, 3:24, 3:25, 3:26, 3:27, 3:28, 3:29, 3:30, 3:31, 3:32, 3:33, 3:34, 3:35, 3:36, 3:37, 3:38, 3:39, 3:40, 3:41, 3:42, 3:43, 3:44, 3:45, 3:46, 3:47, 3:48, 3:49, 3:50, 3:51, 3:52, 3:53, 3:54, 3:55, 3:56, 3:57, 3:58, 3:59, 4:00, 4:01, 4:02, 4:03, 4:04, 4:05, 4:06, 4:07, 4:08, 4:09, 4:10, 4:11, 4:12, 4:13, 4:14, 4:15, 4:16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment