- array_combine: documentation ( source)
- array_multisort: documentation ( source)
- print_r: documentation ( source)
- array_keys: documentation ( source)
<?php
$zm = [
6000 => [
0 => [
'wskaznik' => 100
],
1 => [
'wskaznik' => 100
]
],
8000 => [
0 => [
'wskaznik' => 50
],
1 => [
'wskaznik' => 50
]
],
4000 => [
0 => [
'wskaznik' => 200
],
1 => [
'wskaznik' => 200
]
],
];
$counts = array();
$keys = array_keys($zm);
foreach ($zm as $key => $value){
$counts[] = $value[0]['wskaznik'];
}
$counts_copy = $counts;
array_multisort($counts, $zm);
array_multisort($counts_copy, $keys);
$out = array_combine($keys, $zm);
echo "<pre>";
print_r($out);
echo "</pre>";
exit;