How can I format a text file that the content looks like this:
Col 1 Col 2 Col 3 ...
abcd ab a
ab a abcd
Each string have a different length.
The output I have reached with my PHP code looks quite ugly:
Col 1 Col 2 Col 3 ...
abc abc abc
abc abc abc
My PHP code to create the text file follows:
$tab = "\t\t";
$txtString = "";
foreach ($teams->get() as $team) {
$class = $classes->getClasses($team["class_id"]);
$club = $clubs->get($team["club_number"]);
$txtString .= $class[0]["class_name"] . $tab;
$txtString .= $team["club_number"] . " " . $club[0]["name"] . $team["team_number"] . $tab;
$txtString .= $team["team_leader_name"] . $tab;
$txtString .= $team["team_leader_street"] . $tab;
$txtString .= $team["team_leader_place"] . $tab;
$txtString .= $team["team_leader_phone"] . "
";
}
$file = "Mannschaftsfuehrer.txt";
file_put_contents($file, $txtString);
Can anyone help me to get a well formatted text file? Thanks in advance.