I want to display a greek phrase, namely I want to display each letter down the other and in the case that the are two words I want this output
Κ Η
Α Ρ
Λ Θ
Ω Ε
Σ Σ
I use this code:
<?php
$str = "HELLO HOW YA DOING WORLD?";
$strWords = explode(' ', $str);
$strLettersRowsArr = array_map('str_split', $strWords);
$maxRows = 0;
foreach ($strLettersRowsArr as $lettersArr) {
if (count($lettersArr) > $maxRows) {
$maxRows = count($lettersArr);
}
}
foreach ($strLettersRowsArr as $key => &$lettersArr) {
while (count($lettersArr) < $maxRows) {
$lettersArr[] = ' ';
}
}
unset($lettersArr);
$strLettersColumnsArr = [];
for ($row = 0; $row < $maxRows; $row++) {
$strLettersColumnsArr[] = array_column($strLettersRowsArr, $row);
}
// Print out letter columns.
foreach ($strLettersColumnsArr as $lettersColumnArr) {
foreach ($lettersColumnArr as $letter) {
echo "$letter ";
}
echo "
";
}
?>
But I get this output:
??
??
??
??
??