Removing array index reference when using json_encode()

后端 未结 3 2097
不知归路
不知归路 2020-11-27 19:08

I have made a small application using jQuery\'s datepicker. I am setting unavailable dates to it from a JSON file which looks like this:

{ \"dat         


        
3条回答
  •  攒了一身酷
    2020-11-27 19:23

    You are ignoring the return value of array_values in your existing attempt to reindex the array. Correct is

    $arr['dates'] = array_values($arr['dates']);
    

    The reindexing should also be moved outside the foreach loop, there is no point in reindexing multiple times.

提交回复
热议问题