What Im trying to do is I want to delete specific array index value inside this array that Im comparing it with another array. I heard unset is the way to go so I give it a try. Below is the json encode before the unset().
[
{
"crs_id": "1269",
"crs_code": "UI3/212",
"crs_title_bm": "LOL",
"crs_title_bi": "OLO",
"crs_description_bm": "ye ah tu",
"crs_description_bi": "righttt",
"crs_edit_by": "991018222222",
"crs_edit_date": "2022-04-11 05:43:30",
"crs_aprv_type1": "0",
"crs_aprv_val1": null,
"crs_aprv_type2": "0",
"crs_aprv_val2": null,
"crs_aprv_type3": "0",
"crs_aprv_val3": null,
"crs_aprv_type4": "0",
"crs_aprv_val4": null,
"crs_aprv_type5": "0",
"crs_aprv_val5": null,
"crs_indakua": "1",
"crs_indpengembangan": "0",
"crs_status": "1",
"cat_id": "27",
"typ_id": "7",
"clssfctn_id": "8",
"crs_grp_id": "8",
"crs_org_id": "16",
"cdept_id": "40408000017"
},
{
"crs_id": "1270",
"crs_code": "ABC18",
"crs_title_bm": "LOL2",
"crs_title_bi": "OLO2",
"crs_description_bm": "yow",
"crs_description_bi": "right",
"crs_edit_by": "991018222222",
"crs_edit_date": "2022-04-11 05:42:52",
"crs_aprv_type1": "0",
"crs_aprv_val1": null,
"crs_aprv_type2": "0",
"crs_aprv_val2": null,
"crs_aprv_type3": "0",
"crs_aprv_val3": null,
"crs_aprv_type4": "0",
"crs_aprv_val4": null,
"crs_aprv_type5": "0",
"crs_aprv_val5": null,
"crs_indakua": "1",
"crs_indpengembangan": "0",
"crs_status": "1",
"cat_id": "27",
"typ_id": "7",
"clssfctn_id": "4",
"crs_grp_id": "9",
"crs_org_id": "11",
"cdept_id": "40405000000"
},
{
"crs_id": "1271",
"crs_code": "TIME12",
"crs_title_bm": "CHECK",
"crs_title_bi": "CHECK",
"crs_description_bm": "nk check it is mase",
"crs_description_bi": "nk check it is mase",
"crs_edit_by": "991018222222",
"crs_edit_date": "2022-04-11 05:41:54",
"crs_aprv_type1": "0",
"crs_aprv_val1": null,
"crs_aprv_type2": "0",
"crs_aprv_val2": null,
"crs_aprv_type3": "0",
"crs_aprv_val3": null,
"crs_aprv_type4": "0",
"crs_aprv_val4": null,
"crs_aprv_type5": "0",
"crs_aprv_val5": null,
"crs_indakua": "1",
"crs_indpengembangan": "0",
"crs_status": "1",
"cat_id": "27",
"typ_id": "4",
"clssfctn_id": "4",
"crs_grp_id": "3",
"crs_org_id": "18",
"cdept_id": "40408000034"
}
]
It is exactly what I hope to see so nothing wrong here. Below is the json encode after the unset().
{
"1": {
"crs_id": "1270",
"crs_code": "ABC18",
"crs_title_bm": "LOL2",
"crs_title_bi": "OLO2",
"crs_description_bm": "yow",
"crs_description_bi": "right",
"crs_edit_by": "991018222222",
"crs_edit_date": "2022-04-11 05:42:52",
"crs_aprv_type1": "0",
"crs_aprv_val1": null,
"crs_aprv_type2": "0",
"crs_aprv_val2": null,
"crs_aprv_type3": "0",
"crs_aprv_val3": null,
"crs_aprv_type4": "0",
"crs_aprv_val4": null,
"crs_aprv_type5": "0",
"crs_aprv_val5": null,
"crs_indakua": "1",
"crs_indpengembangan": "0",
"crs_status": "1",
"cat_id": "27",
"typ_id": "7",
"clssfctn_id": "4",
"crs_grp_id": "9",
"crs_org_id": "11",
"cdept_id": "40405000000"
}
}
The above json encode is still what I hope to see, it show the correct array key index to be shown but what make it a problem for me is the value "1"
suddenly appear and I noticed it no longer in an array form(?) since before unset it shown [.....]
but after unset it shown {....}
What I want to see is the "1"
is gone and instead of {....}
I want it to be [.....]