Unsetting index in array turns it to an object

前端 未结 2 1440
感情败类
感情败类 2021-01-21 09:42

So I have a JSON document I\'m storing in CouchDB. Here\'s the important part of it:

\"games\": {
   \"creator\": [
       \"cf86d68b24c1bbf22702356572027642\",         


        
2条回答
  •  死守一世寂寞
    2021-01-21 10:30

    Instead of using unset, use array_splice. This will automatically adjust the array indexes:

    array_splice($user->games->creator, 1, 1);
    

提交回复
热议问题