I want to output data with variable length in columns in a php-cli script
Example:
$pepole = Array(
'Mirco Dellarovere' => 'Artista',
'Nino Pepe' => 'Attore',
'Zoe Yan' => 'Futurista',
'Mino' => 'Elettricista'
);
foreach($pepole as $name => $work)
{
echo "$name\t$work\n";
}
The output will be
Mirco Dellarovere Artista
Nino Pepe Attore
Zoe Yan Futurista
Mino Elettricista
but i want it this way
Mirco Dellarovere Artista
Nino Pepe Attore
Zoe Yan Futurista
Mino Elettricista
how to?
🙂 thanks
You can pad
$nameto ensure a standard number of characters. Just ensure that the number of characters(20) is equal to or larger than the length of the longest name: