Skip to content

Instantly share code, notes, and snippets.

@dstogov
Created May 21, 2019 10:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dstogov/7f28a20ef77197a86ab3120bdbd0006f to your computer and use it in GitHub Desktop.
Save dstogov/7f28a20ef77197a86ab3120bdbd0006f to your computer and use it in GitHub Desktop.
<?php
function getDurationIntervals($intervals = array() ) {
$smallestInterval = null;
$segments = array();
foreach ( $intervals as $name => $length ) {
if ( $length > 0 || ( $name === $smallestInterval && empty( $segments ) ) ) {
$segments[$name] = $length;
}
}
return $segments;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment