deleting JSON array element in PHP, and re-encoding as JSON

前端 未结 3 1364
梦如初夏
梦如初夏 2021-01-15 13:10
function deleteNews($selected) {
    $file = file_get_contents(\'news.json\', true);

    $data=json_decode($file,true);
    unset($file);

foreach($selected as $ind         


        
3条回答
  •  南方客
    南方客 (楼主)
    2021-01-15 13:35

    Try it with array_values:

    $result = json_encode(array_values($data));
    

提交回复
热议问题