Should put $duration = array() at the top. Initializing duration will output an empty string when $period is 0 or you otherwise get an error. Useful in situations where you calculate the duration of something that may not have started yet and makes it a bit more solid and stable overall by covering this edge case.