something along the lines of....
$sql = \'SELECT desired_field_or_all FROM ur_table\';
$result = @mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($result))
{
$field_value = $row[\'desired_field\'];
list($part_a, $part_b) = explode(\'-\', $field_value);
if(strlen($part_b) is less than 4)
{
//prepend 0\'s and implode with $part_a ...and a dash;)
//of course this loop may go further becuase it could be 1, 2 or 3 less;
//then update same field in db with new $field_value;
}
..on a note i myself am learning php so the (pseudo)code may not be perfect