取消设置数组项并更新json对象

I have json like below , what I want is to unset array value from it and update the json ,like an array in "pstsg" have "min" = 0 will unset but not update the json

"g": {
    "mid": 1478144134757,
    "gid": "0021600062",
    "gdte": "2016-11-02",
    "htm": "2016-11-02T19:00:00",
    "vtm": "2016-11-02T20:00:00",
    "etm": "2016-11-02T21:00:00",
    "gdtutc": "2016-11-03",
    "utctm": "01:00",
    "ac": "Salt Lake City",
    "as": "UT",
    "gcode": "20161102/DALUTA",
    "next": "http://abcd.json",
    "ar": 0,
    "p": 4,
    "st": 3,
    "stt": "Final",
    "cl": "00:00.0",
    "lpla": {
        "evt": 493,
        "cl": "00:00.0",
        "de": "End Period",
        "locX": 0,
        "locY": -80,
        "opt1": 0,
        "opt2": 0,
        "mtype": 0,
        "etype": 13,
        "opid": "",
        "tid": 0,
        "pid": 0,
        "hs": 97,
        "vs": 81,
        "epid": "",
        "oftid": 1610612762
    },
    "vls": {
        "q1": 14,
        "s": 81,
        "ftout": 0,
        "stout": 1,
        "ta": "DAL",
        "tstsg": {
            "fga": 77,
            "fgm": 33,
            "tpa": 26,
            "tpm": 7,
            "fta": 10,
            "ftm": 8,
            "oreb": 6,
            "dreb": 30,
            "reb": 36,
            "ast": 18,
            "stl": 4,
            "blk": 4,
            "pf": 20,
            "tov": 12,
            "fbpts": 0,
            "fbptsa": 1,
            "fbptsm": 0,
            "pip": 28,
            "pipa": 27,
            "pipm": 14,
            "ble": 1,
            "bpts": 32,
            "tf": 2,
            "scp": 0
        },
        "pstsg": [
            {
                "fn": "Harrison",
                "ln": "Barnes",
                "num": "40",
                "pos": "F",
                "min": 35,
                "sec": 42,
                "totsec": 2142,
                "fga": 13,
                "fgm": 6,
                "tpa": 3,
                "tpm": 0,
                "fta": 2,
                "ftm": 2,
                "oreb": 0,
                "dreb": 2,
                "reb": 2,
                "ast": 1,
                "stl": 0,
                "blk": 1,
                "pf": 1,
                "pts": 14,
                "tov": 1,
                "fbpts": 0,
                "fbptsa": 0,
                "fbptsm": 0,
                "pip": 0,
                "pipa": 1,
                "pipm": 0,
                "court": 0,
                "pid": 203084,
                "pm": -13,
                "blka": 0,
                "tf": 0,
                "status": "A"
            },
            {
                "fn": "Dirk",
                "ln": "Nowitzki",
                "num": "41",
                "pos": "F",
                "min": 0,
                "sec": 48,
                "totsec": 1728,
                "fga": 14,
                "fgm": 4,
                "tpa": 5,
                "tpm": 0,
                "fta": 1,
                "ftm": 1,
                "oreb": 1,
                "dreb": 4,
                "reb": 5,
                "ast": 0,
                "stl": 1,
                "blk": 0,
                "pf": 3,
                "pts": 9,
                "tov": 1,
                "fbpts": 0,
                "fbptsa": 0,
                "fbptsm": 0,
                "pip": 8,
                "pipa": 5,
                "pipm": 4,
                "court": 0,
                "pid": 1717,
                "pm": -20,
                "blka": 1,
                "tf": 0,
                "status": "A"
            },

what I want is delete unset array value and update json object aswell.

foreach ($gdUrl_data as $key => $value) {
    $vpstgcount = count($value["vls"]["pstsg"]);
    for ($j = 0; $j <$vpstgcount; $j++) {
        $minVal = $value["vls"]["pstsg"][$j]["min"];
        if ($minVal == 0)
        {
            unset($value["vls"]["pstsg"][$j]);
        }
    }
  }
    $gdUrl_data = json_encode($gdUrl_data);

this will unset the array but not update the json .

function unsetKey($json, $key) {
    $json = json_decode($json, true);
    unset($json[$key]);
    return json_encode($json);
}

$value is a copy of the array element, so when you unset parts of it you're not affecting the original array. If you want it to be the actual array element, use a reference variable:

foreach ($gdUrl_data as &$value) {
    foreach ($value["vls"]["pstg"] as $j => $el) {
        if ($el["min"] == 0) {
            unset($value[$j]);
        }
    }
}