3v4l.org

run code in 300+ PHP versions simultaneously
<?php $words=['MVW','MWAH','MWAH','MYW','MW','MY9AH','MYQAH','MYQAH','MY9AH','MYQAH', 'MYQAH','MWAH','MYQAH','MYSWI','MYQAH','MYQAH','MW','MW','MW','MW']; echo "*** Step #1: Replace each word with an array of its characters ***\n"; var_export(array_map('str_split',$words)); echo "\n\n---\n\n"; echo "*** Step #2: Pass the characters through array_map with the splat operator and func_get_args() to isolate columnar data including NULLs where no character exists in the column ***\n"; var_export(array_map(function(){return func_get_args();},...array_map('str_split',$words))); echo "\n\n---\n\n"; echo "*** Step #3: Convert column data to strings with the added benefit of eliminating NULLs ***\n"; //var_export(array_map(function(){return implode(func_get_args());},...array_map('str_split',$words))); echo "\n\n---\n\n"; echo "*** Step #4: Count the occurrences of each character; stored as ord values as keys, and occurrences as values ***\n"; var_export(array_map(function(){return count_chars(implode(func_get_args()),1);},...array_map('str_split',$words))); echo "\n\n---\n\n"; echo "*** Step #5: Sort DESC while preserving keys ***\n"; var_export(array_map(function(){$occurrences=count_chars(implode(func_get_args()),1); arsort($occurrences); return $occurrences;},...array_map('str_split',$words))); echo "\n\n---\n\n"; echo "*** Step #6: Target the first (highest occurring) value/character in the array ***\n"; var_export(array_map(function(){$occurrences=count_chars(implode(func_get_args()),1); arsort($occurrences); return key($occurrences);},...array_map('str_split',$words))); echo "\n\n---\n\n"; echo "*** Step #7: Convert the targeted character from ord() to chr() ***\n"; var_export(array_map(function(){$occurrences=count_chars(implode(func_get_args()),1); arsort($occurrences); return chr(key($occurrences));},...array_map('str_split',$words)));

preferences:
26.75 ms | 402 KiB | 5 Q