<?php
$arr = array (
0 =>
array (
'N_127y4Gral' =>
array (
0 => '302',
),
),
1 =>
array (
'N_127y4Gral' =>
array (
0 => '288',
),
),
2 =>
array (
'N_144y4Gral' =>
array (
0 => '317',
),
),
3 =>
array (
'N_144y4Gral' =>
array (
0 => '307',
),
),
4 =>
array (
'N_144y4Gral' =>
array (
0 => '332',
),
));
foreach($arr as $sub){
foreach($sub as $key => $val){
$res[$key][] = $val[0];
if(!isset($count[$key])){
$count[$key] = 1;
}else{
$count[$key]++;
}
}
}
$max = max($count);
foreach($res as &$subarray){
$subarray = array_merge($subarray, array_fill(0,$max-count($subarray), 0));
}
var_dump($res);
- Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 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 - 8.3.7
- array(2) {
["N_127y4Gral"]=>
array(3) {
[0]=>
string(3) "302"
[1]=>
string(3) "288"
[2]=>
int(0)
}
["N_144y4Gral"]=>
&array(3) {
[0]=>
string(3) "317"
[1]=>
string(3) "307"
[2]=>
string(3) "332"
}
}
- 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
array(2) {
["N_127y4Gral"]=>
array(3) {
[0]=>
string(3) "302"
[1]=>
string(3) "288"
[2]=>
int(0)
}
["N_144y4Gral"]=>
&array(3) {
[0]=>
string(3) "317"
[1]=>
string(3) "307"
[2]=>
string(3) "332"
}
}
preferences:
181.03 ms | 402 KiB | 210 Q