@ 2018-02-20T02:52:55Z <?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)));
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 7.1.0 - 7.1.20 , 7.2.0 - 7.2.33 , 7.3.16 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.4 , 8.3.6 *** Step #1: Replace each word with an array of its characters ***
array (
0 =>
array (
0 => 'M',
1 => 'V',
2 => 'W',
),
1 =>
array (
0 => 'M',
1 => 'W',
2 => 'A',
3 => 'H',
),
2 =>
array (
0 => 'M',
1 => 'W',
2 => 'A',
3 => 'H',
),
3 =>
array (
0 => 'M',
1 => 'Y',
2 => 'W',
),
4 =>
array (
0 => 'M',
1 => 'W',
),
5 =>
array (
0 => 'M',
1 => 'Y',
2 => '9',
3 => 'A',
4 => 'H',
),
6 =>
array (
0 => 'M',
1 => 'Y',
2 => 'Q',
3 => 'A',
4 => 'H',
),
7 =>
array (
0 => 'M',
1 => 'Y',
2 => 'Q',
3 => 'A',
4 => 'H',
),
8 =>
array (
0 => 'M',
1 => 'Y',
2 => '9',
3 => 'A',
4 => 'H',
),
9 =>
array (
0 => 'M',
1 => 'Y',
2 => 'Q',
3 => 'A',
4 => 'H',
),
10 =>
array (
0 => 'M',
1 => 'Y',
2 => 'Q',
3 => 'A',
4 => 'H',
),
11 =>
array (
0 => 'M',
1 => 'W',
2 => 'A',
3 => 'H',
),
12 =>
array (
0 => 'M',
1 => 'Y',
2 => 'Q',
3 => 'A',
4 => 'H',
),
13 =>
array (
0 => 'M',
1 => 'Y',
2 => 'S',
3 => 'W',
4 => 'I',
),
14 =>
array (
0 => 'M',
1 => 'Y',
2 => 'Q',
3 => 'A',
4 => 'H',
),
15 =>
array (
0 => 'M',
1 => 'Y',
2 => 'Q',
3 => 'A',
4 => 'H',
),
16 =>
array (
0 => 'M',
1 => 'W',
),
17 =>
array (
0 => 'M',
1 => 'W',
),
18 =>
array (
0 => 'M',
1 => 'W',
),
19 =>
array (
0 => 'M',
1 => 'W',
),
)
---
*** 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 ***
array (
0 =>
array (
0 => 'M',
1 => 'M',
2 => 'M',
3 => 'M',
4 => 'M',
5 => 'M',
6 => 'M',
7 => 'M',
8 => 'M',
9 => 'M',
10 => 'M',
11 => 'M',
12 => 'M',
13 => 'M',
14 => 'M',
15 => 'M',
16 => 'M',
17 => 'M',
18 => 'M',
19 => 'M',
),
1 =>
array (
0 => 'V',
1 => 'W',
2 => 'W',
3 => 'Y',
4 => 'W',
5 => 'Y',
6 => 'Y',
7 => 'Y',
8 => 'Y',
9 => 'Y',
10 => 'Y',
11 => 'W',
12 => 'Y',
13 => 'Y',
14 => 'Y',
15 => 'Y',
16 => 'W',
17 => 'W',
18 => 'W',
19 => 'W',
),
2 =>
array (
0 => 'W',
1 => 'A',
2 => 'A',
3 => 'W',
4 => NULL,
5 => '9',
6 => 'Q',
7 => 'Q',
8 => '9',
9 => 'Q',
10 => 'Q',
11 => 'A',
12 => 'Q',
13 => 'S',
14 => 'Q',
15 => 'Q',
16 => NULL,
17 => NULL,
18 => NULL,
19 => NULL,
),
3 =>
array (
0 => NULL,
1 => 'H',
2 => 'H',
3 => NULL,
4 => NULL,
5 => 'A',
6 => 'A',
7 => 'A',
8 => 'A',
9 => 'A',
10 => 'A',
11 => 'H',
12 => 'A',
13 => 'W',
14 => 'A',
15 => 'A',
16 => NULL,
17 => NULL,
18 => NULL,
19 => NULL,
),
4 =>
array (
0 => NULL,
1 => NULL,
2 => NULL,
3 => NULL,
4 => NULL,
5 => 'H',
6 => 'H',
7 => 'H',
8 => 'H',
9 => 'H',
10 => 'H',
11 => NULL,
12 => 'H',
13 => 'I',
14 => 'H',
15 => 'H',
16 => NULL,
17 => NULL,
18 => NULL,
19 => NULL,
),
)
---
*** Step #3: Convert column data to strings with the added benefit of eliminating NULLs ***
---
*** Step #4: Count the occurrences of each character; stored as ord values as keys, and occurrences as values ***
array (
0 =>
array (
77 => 20,
),
1 =>
array (
86 => 1,
87 => 8,
89 => 11,
),
2 =>
array (
57 => 2,
65 => 3,
81 => 7,
83 => 1,
87 => 2,
),
3 =>
array (
65 => 9,
72 => 3,
87 => 1,
),
4 =>
array (
72 => 9,
73 => 1,
),
)
---
*** Step #5: Sort DESC while preserving keys ***
array (
0 =>
array (
77 => 20,
),
1 =>
array (
89 => 11,
87 => 8,
86 => 1,
),
2 =>
array (
81 => 7,
65 => 3,
57 => 2,
87 => 2,
83 => 1,
),
3 =>
array (
65 => 9,
72 => 3,
87 => 1,
),
4 =>
array (
72 => 9,
73 => 1,
),
)
---
*** Step #6: Target the first (highest occurring) value/character in the array ***
array (
0 => 77,
1 => 89,
2 => 81,
3 => 65,
4 => 72,
)
---
*** Step #7: Convert the targeted character from ord() to chr() ***
array (
0 => 'M',
1 => 'Y',
2 => 'Q',
3 => 'A',
4 => 'H',
) Output for 8.3.5 Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
*** Step #1: Replace each word with an array of its characters ***
array (
0 =>
array (
0 => 'M',
1 => 'V',
2 => 'W',
),
1 =>
array (
0 => 'M',
1 => 'W',
2 => 'A',
3 => 'H',
),
2 =>
array (
0 => 'M',
1 => 'W',
2 => 'A',
3 => 'H',
),
3 =>
array (
0 => 'M',
1 => 'Y',
2 => 'W',
),
4 =>
array (
0 => 'M',
1 => 'W',
),
5 =>
array (
0 => 'M',
1 => 'Y',
2 => '9',
3 => 'A',
4 => 'H',
),
6 =>
array (
0 => 'M',
1 => 'Y',
2 => 'Q',
3 => 'A',
4 => 'H',
),
7 =>
array (
0 => 'M',
1 => 'Y',
2 => 'Q',
3 => 'A',
4 => 'H',
),
8 =>
array (
0 => 'M',
1 => 'Y',
2 => '9',
3 => 'A',
4 => 'H',
),
9 =>
array (
0 => 'M',
1 => 'Y',
2 => 'Q',
3 => 'A',
4 => 'H',
),
10 =>
array (
0 => 'M',
1 => 'Y',
2 => 'Q',
3 => 'A',
4 => 'H',
),
11 =>
array (
0 => 'M',
1 => 'W',
2 => 'A',
3 => 'H',
),
12 =>
array (
0 => 'M',
1 => 'Y',
2 => 'Q',
3 => 'A',
4 => 'H',
),
13 =>
array (
0 => 'M',
1 => 'Y',
2 => 'S',
3 => 'W',
4 => 'I',
),
14 =>
array (
0 => 'M',
1 => 'Y',
2 => 'Q',
3 => 'A',
4 => 'H',
),
15 =>
array (
0 => 'M',
1 => 'Y',
2 => 'Q',
3 => 'A',
4 => 'H',
),
16 =>
array (
0 => 'M',
1 => 'W',
),
17 =>
array (
0 => 'M',
1 => 'W',
),
18 =>
array (
0 => 'M',
1 => 'W',
),
19 =>
array (
0 => 'M',
1 => 'W',
),
)
---
*** 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 ***
array (
0 =>
array (
0 => 'M',
1 => 'M',
2 => 'M',
3 => 'M',
4 => 'M',
5 => 'M',
6 => 'M',
7 => 'M',
8 => 'M',
9 => 'M',
10 => 'M',
11 => 'M',
12 => 'M',
13 => 'M',
14 => 'M',
15 => 'M',
16 => 'M',
17 => 'M',
18 => 'M',
19 => 'M',
),
1 =>
array (
0 => 'V',
1 => 'W',
2 => 'W',
3 => 'Y',
4 => 'W',
5 => 'Y',
6 => 'Y',
7 => 'Y',
8 => 'Y',
9 => 'Y',
10 => 'Y',
11 => 'W',
12 => 'Y',
13 => 'Y',
14 => 'Y',
15 => 'Y',
16 => 'W',
17 => 'W',
18 => 'W',
19 => 'W',
),
2 =>
array (
0 => 'W',
1 => 'A',
2 => 'A',
3 => 'W',
4 => NULL,
5 => '9',
6 => 'Q',
7 => 'Q',
8 => '9',
9 => 'Q',
10 => 'Q',
11 => 'A',
12 => 'Q',
13 => 'S',
14 => 'Q',
15 => 'Q',
16 => NULL,
17 => NULL,
18 => NULL,
19 => NULL,
),
3 =>
array (
0 => NULL,
1 => 'H',
2 => 'H',
3 => NULL,
4 => NULL,
5 => 'A',
6 => 'A',
7 => 'A',
8 => 'A',
9 => 'A',
10 => 'A',
11 => 'H',
12 => 'A',
13 => 'W',
14 => 'A',
15 => 'A',
16 => NULL,
17 => NULL,
18 => NULL,
19 => NULL,
),
4 =>
array (
0 => NULL,
1 => NULL,
2 => NULL,
3 => NULL,
4 => NULL,
5 => 'H',
6 => 'H',
7 => 'H',
8 => 'H',
9 => 'H',
10 => 'H',
11 => NULL,
12 => 'H',
13 => 'I',
14 => 'H',
15 => 'H',
16 => NULL,
17 => NULL,
18 => NULL,
19 => NULL,
),
)
---
*** Step #3: Convert column data to strings with the added benefit of eliminating NULLs ***
---
*** Step #4: Count the occurrences of each character; stored as ord values as keys, and occurrences as values ***
array (
0 =>
array (
77 => 20,
),
1 =>
array (
86 => 1,
87 => 8,
89 => 11,
),
2 =>
array (
57 => 2,
65 => 3,
81 => 7,
83 => 1,
87 => 2,
),
3 =>
array (
65 => 9,
72 => 3,
87 => 1,
),
4 =>
array (
72 => 9,
73 => 1,
),
)
---
*** Step #5: Sort DESC while preserving keys ***
array (
0 =>
array (
77 => 20,
),
1 =>
array (
89 => 11,
87 => 8,
86 => 1,
),
2 =>
array (
81 => 7,
65 => 3,
57 => 2,
87 => 2,
83 => 1,
),
3 =>
array (
65 => 9,
72 => 3,
87 => 1,
),
4 =>
array (
72 => 9,
73 => 1,
),
)
---
*** Step #6: Target the first (highest occurring) value/character in the array ***
array (
0 => 77,
1 => 89,
2 => 81,
3 => 65,
4 => 72,
)
---
*** Step #7: Convert the targeted character from ord() to chr() ***
array (
0 => 'M',
1 => 'Y',
2 => 'Q',
3 => 'A',
4 => 'H',
) preferences:dark mode live preview
180.24 ms | 413 KiB | 158 Q