I have structure of an array like this :
[{"name":"username1","id":0},{"name":"username2","id":1}]
in my mysql database it is json encoded i am trying to search for a specific id and delete that object and save other array as it is.
$arr_data=json_decode($jsonData);
foreach(arr_data as $k=> $data)
{
if($request->id==$data->id)
{
unset($arr_data[$k]);
$updateData = DataTable::where(['id'=>$request->id])
->update(['update_column' =>json_encode($arr_data)]);
}
}
Issue is my data is not stored in proper format after deleting.
New json formatted data is store in this format :
{"1":{"name":"username1","id":1}}
Any suggestion to solve this issue.