Skip to content

Instantly share code, notes, and snippets.

@shinderuman
Last active October 21, 2021 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shinderuman/34a053640e51b283afc5ce89e7eeaab6 to your computer and use it in GitHub Desktop.
Save shinderuman/34a053640e51b283afc5ce89e7eeaab6 to your computer and use it in GitHub Desktop.
開 水 メ 詳 メ 意
発 を ン し ン 外
部 取 マ く マ に
は り を は は 知
そ 替 戻 「 発 ら
の え す 味 酵 れ
臭 な と 付 食 て
い が き メ 品 い
に ら は ン と な
ク 5 強 マ い い
ラ 日 烈 の う の
ク ぐ な で こ が
ラ ら 臭 き と  
。 い い る    
  煮 が ま    
  る し で    
  の ま 」    
  で す 参    
  す 。 照    
  が   。    
<?php
$array = $argv;
array_shift($array);
$array = count($array) > 1 ? $array : explode(' ', array_shift($array));
function tateyomi(array $array, string $separator = ' '):string {
$max = max(array_map('mb_strlen', $array));
$result = [];
foreach (array_reverse($array) as $v) {
for($i = 0;$i < $max;$i++) {
$c = mb_substr($v, $i, 1);
$result[$i][] = empty($c) ? $separator : $c;
}
}
return str_replace('ー', '|', implode(
PHP_EOL,
array_map(function($array) use ($separator) {
return implode($separator, $array);
}, $result)
));
}
echo tateyomi($array), PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment