We have a lot of strings for storing the time that it took participants to finish the track. There are basically 2 different types of those strings ( <1 hour and >1hour ):
Simple way would be
$time = str_pad($time,8,'00:',STR_PAD_LEFT)
What it does: Fill the string with 00: from left to the full lenght of 8
$time = strlen($time)==8?$time:"00:$time"
What it does: Check if string is 8 chars then do nothing else add 00:
This are solutions if really only the 2 different types are given.
This wont work: