{php}
$format = $this->get_template_vars("phone_number_format");
$values = explode("|", $this->get_template_vars("VALUE"));
$name   = $this->get_template_vars("NAME");

$pieces = preg_split("/(x+)/", $format, 0, PREG_SPLIT_DELIM_CAPTURE);
$counter = 1;
foreach ($pieces as $piece)
{
  if (strlen($piece) == 0)
    continue;

  if ($piece[0] == "x") {
    $size = strlen($piece); 
    $value = (isset($values[$counter-1])) ? $values[$counter-1] : "";
    $value = htmlspecialchars($value);
    echo "<input type=\"text\" name=\"{$name}_$counter\" value=\"$value\"
            size=\"$size\" maxlength=\"$size\" />";
    $counter++;
  } else {
    echo $piece;
  }
}
{/php}
{if $comments}
  <div class="cf_field_comments">{$comments}</div>
{/if}