在phpword中的文本后添加字符“-”

问题描述

我正在使用 PHPword 从 PHP 创建文件 word。 我想通过使用类 PHP word 和这样的文本来制作文件 word

example text line 1
example text line 2
line 3

我想要这样的结果

example text line 1 --------------------------------------
example text line 2 --------------------------------------
line 3 ---------------------------------------------------

我不知道这条线的名称是什么,但我希望有人能帮助我。

解决方法

$lenght = 50;
$lines = ["example text line 1","example text line 2","line 3"];
foreach($lines as $line)
{
  echo str_pad($line,($lenght-strlen($line)),"-");
  echo "\n";
}