Ask the boss for help with the sorting problem of multi-dimensional arrays

convert the json string to a multidimensional array and sort it in ascending order according to key according to ASCII code dictionary order, and remove the null value.

{"tags":[],"shop_id":"3592793253","sub_balance":"7500","diy_gift_coupon_pay":[],"remark":null,"sub_credit":"0","cno":"1177984","cashier_id":"-1","count_num":null,"gift_coupons_ids":["1585459235115551493"],"activity_ids":[],"biz_id":"7177798788424091240","deno_coupon_ids":["1585300479841897178"],"payment_mode":"1","payment_amount":"0","products":[{"tags":[],"num":"1","price":"4800","no":"9003","name":"","is_activity":"2"}],"consume_amount":"17300","credit_amount":null}
Php
Mar.09,2021

<?php

$str = '{"tags":[],"shop_id":"3592793253","sub_balance":"7500","diy_gift_coupon_pay":[],"remark":null,"sub_credit":"0","cno":"1177984","cashier_id":"-1","count_num":null,"gift_coupons_ids":["1585459235115551493"],"activity_ids":[],"biz_id":"7177798788424091240","deno_coupon_ids":["1585300479841897178"],"payment_mode":"1","payment_amount":"0","products":[{"tags":[],"num":"1","price":"4800","no":"9003","name":"","is_activity":"2"}],"consume_amount":"17300","credit_amount":null}
';


$data = json_decode($str,true);
$tmp  = array_filter($data,function($val){
    return $val !== null;
});

ksort($tmp);

var_dump($tmp);
Menu