I have the following array:
Array
(
[ret_code] => 0
[ret_msg] => OK
[result] => Array
(
[0] => Array
(
[symbol] => 10000NFTUSDT
[bid_price] => 0.004085
[ask_price] => 0.004095
[last_price] => 0.004085
[last_tick_direction] => MinusTick
[prev_price_24h] => 0.004090
[price_24h_pcnt] => -0.001222
[high_price_24h] => 0.004120
[low_price_24h] => 0.004040
)
[1] => Array
(
[symbol] => 1000BONKUSDT
[bid_price] => 0.002089
[ask_price] => 0.002092
[last_price] => 0.002093
[last_tick_direction] => PlusTick
[prev_price_24h] => 0.001587
[price_24h_pcnt] => 0.31884
[high_price_24h] => 0.002396
[low_price_24h] => 0.001553
)
[2] => Array
(
[symbol] => 1000BTTUSDT
[bid_price] => 0.000628
[ask_price] => 0.000629
[last_price] => 0.000628
[last_tick_direction] => ZeroMinusTick
[prev_price_24h] => 0.000623
[price_24h_pcnt] => 0.008025
[high_price_24h] => 0.000631
[low_price_24h] => 0.000622
)
)
[ext_code] =>
[ext_info] =>
[time_now] => 1673109990.331754
)
How could I sort this array by the [price_24h_pcnt] nested value?
My ideal output would be simpler array such as... ('1000BONKUSDT', '10000NFTUSDT', '1000BTTUSDT')
I tried using array_column but failed to successfully navigate the nesting. Thank you for any help.
CodePudding user response:
$key_values = array_column($arrayName, 'price_24h_pcnt');
array_multisort($key_values, SORT_ASC, $arrayName);