这是数组,
<input type="range" name="slider-1" id="slider-1" min="1" max="9951" value="1" step="50">
<div data-role="rangeslider" data-track-theme="b" data-theme="a">
<input type="range" name="range1" id="range1" disabled="disabled" min="0" max="10">
<input type="range" name="range2" id="range2" disabled="disabled" value="10">
</div>
大多数usort示例只是2级维度数组。我无法找到任何3级的例子。
在这种情况下,我想排序最先显示的最小点。 Item-A将是第一个,Item-B将是第二个。
答案 0 :(得分:0)
试试这个:
function sort_2d_desc($array, $key) {
usort($array, function($a, $b) use ($key) {
return strnatcasecmp($b[$key], $a[$key]);
});
return $array;
}
$a = [];
foreach($arr as $key => $val){
$a[$key] = $this->sort_2d_desc($val['RedeemOptions'], 'Points');
}
$newArr = [];
foreach($arr as $key => $val){
$newArr[] = ['IdRedeemProduct' => $val['IdRedeemProduct'], 'RedeemOptions' => $a, 'ProductType' => $val['ProductType']];
}
print_r($newArr);
答案 1 :(得分:0)
foreach ($filteredResults as $key => $row)
{
foreach ($row['RedeemOptions'] as $key2 => $option) {
$vc_array_name[$key] = $option['Points'];
}
}
array_multisort($vc_array_name, SORT_ASC, $filteredResults);
这是有效的......